|
dispenso 1.6.0
A library for task parallelism
|
#include <thread_pool.h>
Public Member Functions | |
| AwakeRef (ThreadPool *pool) | |
Acquire a keep-awake reference on pool, incrementing its keep-awake count. | |
| AwakeRef (const AwakeRef &)=delete | |
| AwakeRef (AwakeRef &&other) noexcept | |
Move-construct, transferring the keep-awake reference from other. | |
| void | reset () |
| Release the held keep-awake reference, if any. | |
RAII handle that asks the pool's worker threads to stay awake (skip the sleep transition at the end of their spin window) while at least one AwakeRef is alive on the pool.
Use this around bursts of fine-grained scheduling (e.g. parallel_for) where workers may run out of immediate work mid-burst and would otherwise sleep — paying ~3-5us futex wake latency just to be re-woken on the next task. With AwakeRef held, workers keep spinning instead.
Cost: one fetch_add at construction, one fetch_sub at destruction, one relaxed load in the worker's sleep-decision path. Move-only (non-copyable) to allow transferring ownership while keeping a unique-owner invariant.
Definition at line 229 of file thread_pool.h.
|
inlineexplicit |
Acquire a keep-awake reference on pool, incrementing its keep-awake count.
Definition at line 233 of file thread_pool.h.
|
inlinenoexcept |
Move-construct, transferring the keep-awake reference from other.
Definition at line 241 of file thread_pool.h.
|
inline |
Definition at line 250 of file thread_pool.h.
|
inline |
Release the held keep-awake reference, if any.
Definition at line 254 of file thread_pool.h.