|
|
@ -237,14 +237,13 @@ class DeadlineOps |
|
|
|
public: |
|
|
|
DeadlineOps(ba::io_service& _io, unsigned _reapIntervalMs = 100): m_io(_io), m_reapIntervalMs(_reapIntervalMs), m_stopped(false) { reap(); } |
|
|
|
~DeadlineOps() { stop(); } |
|
|
|
|
|
|
|
void schedule(unsigned _msInFuture, std::function<void(boost::system::error_code const&)> const& _f) { if (m_stopped) return; DEV_GUARDED(x_timers) m_timers.emplace_back(m_io, _msInFuture, _f); } |
|
|
|
|
|
|
|
|
|
|
|
void schedule(unsigned _msInFuture, std::function<void(boost::system::error_code const&)> const& _f) { if (m_stopped) return; DEV_GUARDED(x_timers) m_timers.emplace_back(m_io, _msInFuture, _f); } |
|
|
|
void stop() { m_stopped = true; DEV_GUARDED(x_timers) m_timers.clear(); } |
|
|
|
|
|
|
|
protected: |
|
|
|
void reap() { Guard l(x_timers); auto t = m_timers.begin(); while (t != m_timers.end()) if (t->expired()) { t->wait(); m_timers.erase(t); } else t++; m_timers.emplace_back(m_io, m_reapIntervalMs, [this](boost::system::error_code const& ec){ if (!ec) reap(); }); } |
|
|
|
|
|
|
|
void reap(); |
|
|
|
|
|
|
|
private: |
|
|
|
ba::io_service& m_io; |
|
|
|
unsigned m_reapIntervalMs; |
|
|
|