From: Joel Rosdahl Date: Mon, 27 Oct 2025 20:14:40 +0000 (+0100) Subject: perf: Add fast path in ThreadPool::enqueue X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7213a771410d289187d07f998054b8c900b4aba6;p=thirdparty%2Fccache.git perf: Add fast path in ThreadPool::enqueue --- diff --git a/src/ccache/util/threadpool.cpp b/src/ccache/util/threadpool.cpp index 96aabbbe..ab3ddd20 100644 --- a/src/ccache/util/threadpool.cpp +++ b/src/ccache/util/threadpool.cpp @@ -44,9 +44,11 @@ ThreadPool::enqueue(std::function function) { { std::unique_lock lock(m_mutex); - m_task_popped_condition.wait(lock, [this] { - return m_shutting_down || m_task_queue.size() < m_task_queue_max_size; - }); + if (!m_shutting_down && m_task_queue.size() >= m_task_queue_max_size) { + m_task_popped_condition.wait(lock, [this] { + return m_shutting_down || m_task_queue.size() < m_task_queue_max_size; + }); + } if (m_shutting_down) { return; }