diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-05-28 08:43:25 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-05-28 19:28:21 -0400 |
commit | fac43f9889f500bcb62d830c030dec42fe791031 (patch) | |
tree | 143e5cfafa4a2850d16af163559c86da521c5e70 /src/scheduler.h | |
parent | fa9cca0550f3d0ee8c276146f40007f76fbb97c2 (diff) | |
download | bitcoin-fac43f9889f500bcb62d830c030dec42fe791031.tar.xz |
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.
Diffstat (limited to 'src/scheduler.h')
-rw-r--r-- | src/scheduler.h | 16 |
1 files changed, 12 insertions, 4 deletions
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 |