Added support for threads restart if config changed.
This commit is contained in:
parent
871bc3e180
commit
f590cf58fb
12 changed files with 105 additions and 62 deletions
|
@ -99,6 +99,8 @@ public:
|
|||
xmrig::Miner::Miner(Controller *controller)
|
||||
: d_ptr(new MinerPrivate(controller))
|
||||
{
|
||||
controller->addListener(this);
|
||||
|
||||
d_ptr->timer = new Timer(this);
|
||||
|
||||
d_ptr->backends.push_back(new CpuBackend(controller));
|
||||
|
@ -218,6 +220,20 @@ void xmrig::Miner::stop()
|
|||
}
|
||||
|
||||
|
||||
void xmrig::Miner::onConfigChanged(Config *config, Config *previousConfig)
|
||||
{
|
||||
if (config->pools() != previousConfig->pools() && config->pools().active() > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Job job = this->job();
|
||||
|
||||
for (IBackend *backend : d_ptr->backends) {
|
||||
backend->setJob(job);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Miner::onTimer(const Timer *)
|
||||
{
|
||||
double maxHashrate = 0.0;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <vector>
|
||||
|
||||
|
||||
#include "base/kernel/interfaces/IBaseListener.h"
|
||||
#include "base/kernel/interfaces/ITimerListener.h"
|
||||
|
||||
|
||||
|
@ -41,7 +42,7 @@ class MinerPrivate;
|
|||
class IBackend;
|
||||
|
||||
|
||||
class Miner : public ITimerListener
|
||||
class Miner : public ITimerListener, public IBaseListener
|
||||
{
|
||||
public:
|
||||
Miner(Controller *controller);
|
||||
|
@ -57,6 +58,7 @@ public:
|
|||
void stop();
|
||||
|
||||
protected:
|
||||
void onConfigChanged(Config *config, Config *previousConfig) override;
|
||||
void onTimer(const Timer *timer) override;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue