Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
vault::gear::work Namespace Reference

Typedefs

using SIG_WorkFun = activity::Proc(void)
 config should define a callable with this signature to perform work
 
using SIG_FinalHook = void(bool)
 config should define callable invoked at exit (argument: isFailure)
 
using Launch = lib::Thread::Launch
 

Classes

struct  Config
 Base for configuration of the worker pool. More...
 
class  Worker
 Individual worker thread: repeatedly pulls the doWork functor. More...
 

Functions

void performRandomisedSpin (size_t, size_t)
 This is part of the weak level of anti-contention measures.
 
microseconds steppedRandDelay (size_t, size_t)
 Calculate the delay time for a stronger anti-contention wait.
 

Typedef Documentation

◆ SIG_WorkFun

using SIG_WorkFun = activity::Proc(void)

config should define a callable with this signature to perform work

Definition at line 92 of file work-force.hpp.

◆ SIG_FinalHook

using SIG_FinalHook = void(bool)

config should define callable invoked at exit (argument: isFailure)

Definition at line 93 of file work-force.hpp.

◆ Launch

using Launch = lib::Thread::Launch

Definition at line 120 of file work-force.hpp.

Function Documentation

◆ performRandomisedSpin()

void performRandomisedSpin ( size_t  stepping,
size_t  randFact 
)

This is part of the weak level of anti-contention measures.

When a worker is kicked out from processing due to contention, the immediate reaction is to try again; if this happens repeatedly however, increasingly strong delays are interspersed. Within the weak zone, a short spinning wait is performed, and then the thread requests a yield() from the OS scheduler; this cycle is repeated.

Definition at line 66 of file work-force.cpp.

Referenced by Worker< CONF >::contentionWait().

+ Here is the caller graph for this function:

◆ steppedRandDelay()

microseconds steppedRandDelay ( size_t  stepping,
size_t  randFact 
)

Calculate the delay time for a stronger anti-contention wait.

If the contention lasts, the worker must back out temporarily to allow other workers to catch up. The delay time is stepped up quickly up to a saturation level, where the worker sleeps in the microseconds range — this level is chosen as a balance between retaining some reactivity vs not incurring additional load. The stepping of the anti-contention measures is »sticky« to some degree, because it is not set to zero, once contention ends, but rather stepped down gradually.

Definition at line 82 of file work-force.cpp.

Referenced by Worker< CONF >::contentionWait().

+ Here is the caller graph for this function: