Reimplement whole stratum network communication with boost::asio (#90)

Logger is now thread safe
This commit is contained in:
Ben Gräf 2018-04-14 19:55:13 +02:00 committed by GitHub
parent 15d752d9e0
commit df084acff6
40 changed files with 915 additions and 1942 deletions

View file

@ -81,7 +81,7 @@ DonateStrategy::DonateStrategy(const char *agent, IStrategyListener *listener) :
}
#endif
m_client = new Client(-1, agent, this);
m_client = std::make_shared<Client>(-1, agent, this);
m_client->setUrl(url);
m_client->setRetryPause(Options::i()->retryPause() * 1000);
m_client->setQuiet(true);

View file

@ -65,7 +65,7 @@ private:
static void onSuspendTimer(uv_timer_t *handle);
bool m_active;
Client *m_client;
Client::Ptr m_client;
const int m_donateTime;
const int m_idleTime;
IStrategyListener *m_listener;

View file

@ -57,7 +57,7 @@ void FailoverStrategy::resume()
return;
}
m_listener->onJob( m_pools[m_active], m_pools[m_active]->job());
m_listener->onJob(m_pools[m_active].get(), m_pools[m_active]->job());
}
@ -76,7 +76,7 @@ void FailoverStrategy::stop()
void FailoverStrategy::tick(uint64_t now)
{
for (Client *client : m_pools) {
for (auto client : m_pools) {
client->tick(now);
}
}
@ -140,7 +140,7 @@ void FailoverStrategy::onResultAccepted(Client *client, const SubmitResult &resu
void FailoverStrategy::add(const Url *url, const char *agent)
{
Client *client = new Client((int) m_pools.size(), agent, this);
Client::Ptr client = std::make_shared<Client>((int) m_pools.size(), agent, this);
client->setUrl(url);
client->setRetryPause(Options::i()->retryPause() * 1000);

View file

@ -63,7 +63,7 @@ private:
int m_active;
int m_index;
IStrategyListener *m_listener;
std::vector<Client*> m_pools;
std::vector<Client::Ptr> m_pools;
};
#endif /* __FAILOVERSTRATEGY_H__ */

View file

@ -32,7 +32,7 @@ SinglePoolStrategy::SinglePoolStrategy(const Url *url, const char *agent, IStrat
m_active(false),
m_listener(listener)
{
m_client = new Client(0, agent, this);
m_client = std::make_shared<Client>(0, agent, this);
m_client->setUrl(url);
m_client->setRetryPause(Options::i()->retryPause() * 1000);
}
@ -56,7 +56,7 @@ void SinglePoolStrategy::resume()
return;
}
m_listener->onJob(m_client, m_client->job());
m_listener->onJob(m_client.get(), m_client->job());
}

View file

@ -56,7 +56,7 @@ protected:
private:
bool m_active;
Client *m_client;
Client::Ptr m_client;
IStrategyListener *m_listener;
};