Skip to content

Commit 2f75b94

Browse files
author
Paul T
authored
Merge pull request #75 from willkill07/bugfix-wait_for_tasks
Bugfix: wait_for_tasks should handle spurious wakeups
2 parents bc10764 + 779cc0e commit 2f75b94

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

include/thread_pool/thread_pool.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ namespace dp {
235235
* @details This function will block until all tasks have been completed.
236236
*/
237237
void wait_for_tasks() {
238-
if (in_flight_tasks_.load(std::memory_order_acquire) > 0) {
238+
// must be a while loop to ignore spurious wake-ups
239+
while (in_flight_tasks_.load(std::memory_order_acquire) > 0) {
239240
// wait for all tasks to finish
240241
threads_complete_signal_.wait(false);
241242
}

0 commit comments

Comments
 (0)