From: Joel Rosdahl Date: Mon, 27 Oct 2025 17:51:10 +0000 (+0100) Subject: fix: Start at least one thread in ThreadPool X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83913b569ef3019bc6ee16f0724cf5997e689023;p=thirdparty%2Fccache.git fix: Start at least one thread in ThreadPool --- diff --git a/src/ccache/util/threadpool.cpp b/src/ccache/util/threadpool.cpp index acefbc61..6608dc4d 100644 --- a/src/ccache/util/threadpool.cpp +++ b/src/ccache/util/threadpool.cpp @@ -20,13 +20,16 @@ #include +#include + namespace util { ThreadPool::ThreadPool(size_t number_of_threads, size_t task_queue_max_size) : m_task_queue_max_size(task_queue_max_size) { - m_worker_threads.reserve(number_of_threads); - for (size_t i = 0; i < number_of_threads; ++i) { + size_t actual_threads = std::max(1, number_of_threads); + m_worker_threads.reserve(actual_threads); + for (size_t i = 0; i < actual_threads; ++i) { m_worker_threads.emplace_back(&ThreadPool::worker_thread_main, this); } }