6 #ifndef RAVEN_SCHEDULER_H 7 #define RAVEN_SCHEDULER_H 14 #include <boost/chrono/chrono.hpp> 15 #include <boost/thread.hpp> 47 void schedule(Function f, boost::chrono::system_clock::time_point t=boost::chrono::system_clock::now());
68 void stop(
bool drain=
false);
72 size_t getQueueInfo(boost::chrono::system_clock::time_point &first,
73 boost::chrono::system_clock::time_point &last)
const;
79 std::multimap<boost::chrono::system_clock::time_point, Function>
taskQueue;
85 bool shouldStop()
const {
return stopRequested || (stopWhenEmpty && taskQueue.empty()); }
100 bool m_are_callbacks_running =
false;
102 void MaybeScheduleProcessQueue();
107 void AddToProcessQueue(std::function<
void (
void)> func);
Class used by CScheduler clients which may schedule multiple jobs which are required to be run serial...
std::multimap< boost::chrono::system_clock::time_point, Function > taskQueue
void scheduleEvery(Function f, int64_t deltaMilliSeconds)
void scheduleFromNow(Function f, int64_t deltaMilliSeconds)
void schedule(Function f, boost::chrono::system_clock::time_point t=boost::chrono::system_clock::now())
CScheduler * m_pscheduler
void stop(bool drain=false)
std::function< void(void)> Function
SingleThreadedSchedulerClient(CScheduler *pschedulerIn)
boost::condition_variable newTaskScheduled
boost::mutex newTaskMutex
std::list< std::function< void(void)> > m_callbacks_pending
CCriticalSection m_cs_callbacks_pending
bool AreThreadsServicingQueue() const
int nThreadsServicingQueue
size_t getQueueInfo(boost::chrono::system_clock::time_point &first, boost::chrono::system_clock::time_point &last) const
Wrapped boost mutex: supports recursive locking, but no waiting TODO: We should move away from using ...