Commit 50a82605 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

ThreadPool: Only notify_all when run_cnt is zero (atomic decrement-and-compare)

parent a5b5fdbf
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -125,10 +125,11 @@ void ThreadPool::worker(size_t min_thread_buffer,
                task->get_future().get();
                // Update the run count and propagate update
                std::unique_lock<std::mutex> lock{run_mutex_};
                --run_cnt_;
                if(--run_cnt_ == 0) {
                    run_condition_.notify_all();
                }
            }
        }

        // Execute the cleanup function at the end of run
        if(finalize_function) {