ALib C++ Library
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::threadmodel::ThreadPool::ResizeStrategy Struct Reference

Description:

The set of management parameters that determine how a thread pool balances the number of worker threads.

Definition at line 110 of file threadpool.inl.

Public Type Index:

enum class  Modes { Fixed , Auto }
 The modes, fixed or automatic. More...
 

Public Field Index:

Ticks::Duration DecreaseSchedule = Ticks::Duration::FromAbsoluteMilliseconds(500)
 
int DecreaseThreshold = 70
 
Ticks::Duration IncreaseSchedule = Ticks::Duration::FromAbsoluteMilliseconds(0)
 
int IncreaseThreshold = 300
 
Modes Mode =Modes::Auto
 The mode of operation.
 
int WorkersMax = HardwareConcurrency()
 
int WorkersMin = 0
 The minimum number of threads to keep alive.
 

Protected Method Index:

int GetSize (int currentWorkers, int idleWorkers, int load, Ticks &lastChangeTime)
 

Friends And Related Entity Details:

◆ ThreadPool

friend class ThreadPool
friend

Type alias in namespace alib.

Definition at line 112 of file threadpool.inl.

Enumeration Details:

◆ Modes

enum class alib::threadmodel::ThreadPool::ResizeStrategy::Modes
strong

The modes, fixed or automatic.

Enumerator
Fixed 

The number of threads is fixed.

Auto 

The number of threads is increased when the load increases and decreased when the load decreases.

Definition at line 115 of file threadpool.inl.

Field Details:

◆ DecreaseSchedule

Ticks::Duration alib::threadmodel::ThreadPool::ResizeStrategy::DecreaseSchedule = Ticks::Duration::FromAbsoluteMilliseconds(500)

The duration of that the pool has to be underloaded before a decrease of threads starts. Defaults to 500ms.

Definition at line 156 of file threadpool.inl.

◆ DecreaseThreshold

int alib::threadmodel::ThreadPool::ResizeStrategy::DecreaseThreshold = 70

A threshold in percent that determines at which underload factor the number of threads are decreased. Defaults to 50%. For example, 30% this means that if 70% of the threads are idle the number of threads is decreased.

Definition at line 147 of file threadpool.inl.

◆ IncreaseSchedule

Ticks::Duration alib::threadmodel::ThreadPool::ResizeStrategy::IncreaseSchedule = Ticks::Duration::FromAbsoluteMilliseconds(0)

The duration of that the pool has to be overloaded before an increase of threads starts. Defaults to zero time interval.

Definition at line 152 of file threadpool.inl.

◆ IncreaseThreshold

int alib::threadmodel::ThreadPool::ResizeStrategy::IncreaseThreshold = 300

A threshold in percent that determines at which overload factor the number of threads is increased. Defaults to 300%. For example, this means if the pool currently holds 10 threads, then new threads are created when the load increases to 30 unprocess jobs.

Definition at line 140 of file threadpool.inl.

◆ Mode

Modes alib::threadmodel::ThreadPool::ResizeStrategy::Mode =Modes::Auto

The mode of operation.

Definition at line 126 of file threadpool.inl.

◆ WorkersMax

int alib::threadmodel::ThreadPool::ResizeStrategy::WorkersMax = HardwareConcurrency()

If Mode equals Fixed, this is used and all other parameters are ignored. If Mode equals Auto, this field gives the maximum number of workers that are run in parallel.

Definition at line 131 of file threadpool.inl.

◆ WorkersMin

int alib::threadmodel::ThreadPool::ResizeStrategy::WorkersMin = 0

The minimum number of threads to keep alive.

Definition at line 134 of file threadpool.inl.

Method Details:

◆ GetSize()

int alib::threadmodel::ThreadPool::ResizeStrategy::GetSize ( int currentWorkers,
int idleWorkers,
int load,
Ticks & lastChangeTime )
inlineprotected

Calculates the target size, depending on the parameters set in this struct and the actual values passed.

Parameters
currentWorkersThe number of threads currently in the pool.
idleWorkersThe size of the subset of threads currently idle.
loadThe number of jobs currently queued.
lastChangeTimeTime point of last increase or decrease.
Returns
The new target size.

Definition at line 168 of file threadpool.inl.

Here is the call graph for this function:

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