From fac43f9889f500bcb62d830c030dec42fe791031 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 28 May 2020 08:43:25 -0400 Subject: scheduler: Replace stop(true) with StopWhenDrained() This helps understanding the code at the call site without having to look up the name of the argument or the default value. --- src/scheduler.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/scheduler.h') diff --git a/src/scheduler.h b/src/scheduler.h index 7ebe3df37f..63f20f1335 100644 --- a/src/scheduler.h +++ b/src/scheduler.h @@ -65,10 +65,18 @@ public: // and interrupted using boost::interrupt_thread 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 there is no work left to be done (drain=true) - void stop(bool drain=false); + /** Tell any threads running serviceQueue to stop as soon as the current task is done */ + 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, // and first and last task times -- cgit v1.2.3