From 5294d70d1cb1a77998b8ef41e90cd503b280f084 Mon Sep 17 00:00:00 2001 From: Mikhail Filimonov Date: Tue, 6 Feb 2024 23:50:57 +0100 Subject: [PATCH] more2 --- src/Common/ThreadPool.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Common/ThreadPool.cpp b/src/Common/ThreadPool.cpp index 3ddc68f70fae..054ee536b80c 100644 --- a/src/Common/ThreadPool.cpp +++ b/src/Common/ThreadPool.cpp @@ -665,10 +665,14 @@ void ThreadPoolImpl::worker(typename std::list::iterator thread_ --scheduled_jobs; calculateDesiredThreadPoolSizeNoLock(); - job_finished.notify_one(); + if (scheduled_jobs == 0) { - job_finished.notify_all(); + job_finished.notify_all(); // one of the threads can be waiting in wait() for that condition + } + else + { + job_finished.notify_one(); } }