Changeset View
Changeset View
Standalone View
Standalone View
src/scheduler.h
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | public: | ||||
* to be delta_seconds sooner. | * to be delta_seconds sooner. | ||||
*/ | */ | ||||
void MockForward(std::chrono::seconds delta_seconds); | void MockForward(std::chrono::seconds delta_seconds); | ||||
// Services the queue 'forever'. Should be run in a thread, and interrupted | // Services the queue 'forever'. Should be run in a thread, and interrupted | ||||
// using boost::interrupt_thread | // using boost::interrupt_thread | ||||
void serviceQueue(); | void serviceQueue(); | ||||
// Tell any threads running serviceQueue to stop as soon as they're done | /** | ||||
// servicing whatever task they're currently servicing (drain=false) or when | * Tell any threads running serviceQueue to stop as soon as the current | ||||
// there is no work left to be done (drain=true) | * task is done | ||||
void stop(bool drain = false); | */ | ||||
void stop() { | |||||
WITH_LOCK(newTaskMutex, stopRequested = true); | |||||
newTaskScheduled.notify_all(); | |||||
} | |||||
/** | |||||
* Tell any threads running serviceQueue to stop when there is no work | |||||
* left to be done | |||||
*/ | |||||
void StopWhenDrained() { | |||||
WITH_LOCK(newTaskMutex, stopWhenEmpty = true); | |||||
newTaskScheduled.notify_all(); | |||||
} | |||||
// Returns number of tasks waiting to be serviced, | // Returns number of tasks waiting to be serviced, | ||||
// and first and last task times | // and first and last task times | ||||
size_t getQueueInfo(std::chrono::system_clock::time_point &first, | size_t getQueueInfo(std::chrono::system_clock::time_point &first, | ||||
std::chrono::system_clock::time_point &last) const; | std::chrono::system_clock::time_point &last) const; | ||||
// Returns true if there are threads actively running in serviceQueue() | // Returns true if there are threads actively running in serviceQueue() | ||||
bool AreThreadsServicingQueue() const; | bool AreThreadsServicingQueue() const; | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |