From b91616e2f1abd16b4cd9ce7de44b75aa3a2a9b7e Mon Sep 17 00:00:00 2001 From: PA Dev Bot <344001113+pa-devbot@users.noreply.github.com> Date: Sat, 31 Oct 2026 11:25:02 +0000 Subject: [PATCH] Thread pool: spawn threads in dispatch() dispatch() enqueued the task and called notify_one(), but never called spawn_threads(). Since all of the global pools start with zero threads, a plain dispatch() on a cold pool woke no one and the task never ran. On a pool with fewer threads than its maximum, the pool also never grew to use the headroom. dispatch_now_blocking(), try_dispatch_now() and run_in_parallel() all call spawn_threads(), so only the plain dispatch() path was affected. Call spawn_threads() after the task is enqueued, the same as the other entry points. --- Common/Cpp/Concurrency/Backends/ThreadPool_Default.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Common/Cpp/Concurrency/Backends/ThreadPool_Default.cpp b/Common/Cpp/Concurrency/Backends/ThreadPool_Default.cpp index acf1edea93..297ba275cb 100644 --- a/Common/Cpp/Concurrency/Backends/ThreadPool_Default.cpp +++ b/Common/Cpp/Concurrency/Backends/ThreadPool_Default.cpp @@ -99,6 +99,13 @@ AsyncTask ThreadPool_Default::dispatch(std::function&& func){ task = AsyncTask(std::make_unique(std::move(func))); ptr = task.core(); ptr->report_started(); + + // Spawn threads to pick up the work. Without this, a pool that + // has not reached its maximum thread count (or has no threads + // at all, as the global pools start out) would never grow, and + // with no threads the notify_one() below would wake nothing and + // the task would never run. + spawn_threads(); }catch (...){ m_queue.pop_back(); throw;