Browse Source

static to member in Host::run()

cl-refactor
subtly 10 years ago
parent
commit
b10eddc85e
  1. 9
      libp2p/Host.cpp
  2. 1
      libp2p/Host.h

9
libp2p/Host.cpp

@ -700,8 +700,7 @@ PeerInfos Host::peers(bool _updatePing) const
void Host::run(boost::system::error_code const& error)
{
static unsigned s_lastTick = 0;
s_lastTick += c_timerInterval;
m_lastTick += c_timerInterval;
if (error || !m_ioService)
{
@ -713,11 +712,11 @@ void Host::run(boost::system::error_code const& error)
// network running
if (m_run)
{
if (s_lastTick >= c_timerInterval * 10)
if (m_lastTick >= c_timerInterval * 10)
{
growPeers();
prunePeers();
s_lastTick = 0;
m_lastTick = 0;
}
if (m_hadNewNodes)
@ -783,7 +782,7 @@ void Host::run(boost::system::error_code const& error)
m_socket->close();
// m_run is false, so we're stopping; kill timer
s_lastTick = 0;
m_lastTick = 0;
// causes parent thread's stop() to continue which calls stopWorking()
m_timer.reset();

1
libp2p/Host.h

@ -241,6 +241,7 @@ private:
std::unique_ptr<boost::asio::deadline_timer> m_timer; ///< Timer which, when network is running, calls scheduler() every c_timerInterval ms.
static const unsigned c_timerInterval = 100; ///< Interval which m_timer is run when network is connected.
unsigned m_lastTick = 0; ///< Used by run() for scheduling; must not be mutated outside of run().
std::set<Node*> m_pendingNodeConns; /// Used only by connect(Node&) to limit concurrently connecting to same node. See connect(shared_ptr<Node>const&).
Mutex x_pendingNodeConns;

Loading…
Cancel
Save