dispenso 1.6.0
A library for task parallelism
Loading...
Searching...
No Matches
dispenso::ThreadPool::AwakeRef Class Reference

#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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ AwakeRef() [1/2]

dispenso::ThreadPool::AwakeRef::AwakeRef ( ThreadPool * pool)
inlineexplicit

Acquire a keep-awake reference on pool, incrementing its keep-awake count.

Definition at line 233 of file thread_pool.h.

◆ AwakeRef() [2/2]

dispenso::ThreadPool::AwakeRef::AwakeRef ( AwakeRef && other)
inlinenoexcept

Move-construct, transferring the keep-awake reference from other.

Definition at line 241 of file thread_pool.h.

◆ ~AwakeRef()

dispenso::ThreadPool::AwakeRef::~AwakeRef ( )
inline

Definition at line 250 of file thread_pool.h.

Member Function Documentation

◆ reset()

void dispenso::ThreadPool::AwakeRef::reset ( )
inline

Release the held keep-awake reference, if any.

Definition at line 254 of file thread_pool.h.


The documentation for this class was generated from the following file: