Commit a76404a1 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

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

(cherry picked from commit 50a82605)
parent ae24fb89
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -116,10 +116,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) {