Changeset View
Changeset View
Standalone View
Standalone View
src/scheduler.cpp
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | while (!shouldStop()) { | ||||
--nThreadsServicingQueue; | --nThreadsServicingQueue; | ||||
throw; | throw; | ||||
} | } | ||||
} | } | ||||
--nThreadsServicingQueue; | --nThreadsServicingQueue; | ||||
newTaskScheduled.notify_one(); | newTaskScheduled.notify_one(); | ||||
} | } | ||||
void CScheduler::stop(bool drain) { | |||||
{ | |||||
LOCK(newTaskMutex); | |||||
if (drain) { | |||||
stopWhenEmpty = true; | |||||
} else { | |||||
stopRequested = true; | |||||
} | |||||
} | |||||
newTaskScheduled.notify_all(); | |||||
} | |||||
void CScheduler::schedule(CScheduler::Function f, | void CScheduler::schedule(CScheduler::Function f, | ||||
std::chrono::system_clock::time_point t) { | std::chrono::system_clock::time_point t) { | ||||
{ | { | ||||
LOCK(newTaskMutex); | LOCK(newTaskMutex); | ||||
taskQueue.insert(std::make_pair(t, f)); | taskQueue.insert(std::make_pair(t, f)); | ||||
} | } | ||||
newTaskScheduled.notify_one(); | newTaskScheduled.notify_one(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |