thread_pool: use producer token on fast path of enqueue_work_autoscale

The PToken overload of enqueue_work_autoscale passed ptok_ to the
blocking fallback enqueue but not to the try_enqueue fast path.
BoundedQueue has a try_enqueue(PToken&, ...) overload, so the token
was silently ignored on the common (non-full) path, forgoing the
per-producer thread-local allocation that moodycamel provides.

Pass ptok_ through to try_enqueue so the fast path benefits from the
same producer-token locality as the fallback path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Antonio S. Musumeci 2026-04-10 18:20:14 -04:00
parent 375f1f9303
commit 2d3528431b

View file

@ -1059,7 +1059,7 @@ ThreadPool::enqueue_work_autoscale(ThreadPool::PToken &ptok_,
// that could violate this ordering.
Func f(std::forward<FuncType>(func_));
if(_queue.try_enqueue(std::move(f)))
if(_queue.try_enqueue(ptok_,std::move(f)))
{
_tasks_enqueued.fetch_add(1,std::memory_order_relaxed);
return;