11 #include <boost/bind.hpp> 24 #if BOOST_VERSION < 105000 29 return boost::posix_time::from_time_t(0) + boost::posix_time::milliseconds(boost::chrono::duration_cast<boost::chrono::milliseconds>(t.time_since_epoch()).
count());
57 #if BOOST_VERSION < 105000 67 if (
newTaskScheduled.wait_until<>(lock, timeToWaitFor) == boost::cv_status::timeout)
117 schedule(f, boost::chrono::system_clock::now() + boost::chrono::milliseconds(deltaMilliSeconds));
123 s->
scheduleFromNow(boost::bind(&Repeat, s,
f, deltaMilliSeconds), deltaMilliSeconds);
128 scheduleFromNow(boost::bind(&Repeat,
this, f, deltaMilliSeconds), deltaMilliSeconds);
151 LOCK(m_cs_callbacks_pending);
155 if (m_are_callbacks_running)
return;
156 if (m_callbacks_pending.empty())
return;
162 std::function<void (void)> callback;
164 LOCK(m_cs_callbacks_pending);
165 if (m_are_callbacks_running)
return;
166 if (m_callbacks_pending.empty())
return;
167 m_are_callbacks_running =
true;
169 callback = std::move(m_callbacks_pending.front());
170 m_callbacks_pending.pop_front();
175 struct RAIICallbacksRunning {
178 ~RAIICallbacksRunning() {
185 } raiicallbacksrunning(
this);
194 LOCK(m_cs_callbacks_pending);
195 m_callbacks_pending.emplace_back(std::move(func));
197 MaybeScheduleProcessQueue();
201 assert(!m_pscheduler->AreThreadsServicingQueue());
202 bool should_continue =
true;
203 while (should_continue) {
205 LOCK(m_cs_callbacks_pending);
206 should_continue = !m_callbacks_pending.empty();
Class used by CScheduler clients which may schedule multiple jobs which are required to be run serial...
#define function(a, b, c, d, k, s)
void RandAddSeedSleep()
Add a little bit of randomness to the output of GetStrongRangBytes.
std::multimap< boost::chrono::system_clock::time_point, Function > taskQueue
void MaybeScheduleProcessQueue()
void scheduleEvery(Function f, int64_t deltaMilliSeconds)
assert(len-trim+(2 *lenIndices)<=WIDTH)
void scheduleFromNow(Function f, int64_t deltaMilliSeconds)
void schedule(Function f, boost::chrono::system_clock::time_point t=boost::chrono::system_clock::now())
void stop(bool drain=false)
std::function< void(void)> Function
boost::condition_variable newTaskScheduled
size_t getQueueInfo(boost::chrono::system_clock::time_point &first, boost::chrono::system_clock::time_point &last) const
An RAII-style reverse lock.
bool m_are_callbacks_running
bool AreThreadsServicingQueue() const
boost::mutex newTaskMutex
CCriticalSection m_cs_callbacks_pending
clock::time_point time_point
int nThreadsServicingQueue
void AddToProcessQueue(std::function< void(void)> func)