The set of management parameters that determine how a thread pool balances the number of worker threads.
Definition at line 96 of file threadpool.hpp.
#include <threadpool.hpp>
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 |
int | FixedSize = ThreadPool::HardwareConcurrency() |
Ticks::Duration | IncreaseSchedule = Ticks::Duration::FromAbsoluteMilliseconds(0) |
int | IncreaseThreshold = 300 |
Modes | Mode =Modes::Auto |
The mode of operation. | |
int | WorkersMax = ThreadPool::HardwareConcurrency() |
The maximum number of threads to create. | |
int | WorkersMin = 0 |
The minimum number of threads to keep alive. | |
Protected Method Index: | |
int | GetSize (int currentWorkers, int idleWorkers, int load, Ticks &lastChangeTime) |
|
friend |
Type alias in namespace alib.
Definition at line 98 of file threadpool.hpp.
|
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 101 of file threadpool.hpp.
Ticks::Duration 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 145 of file threadpool.hpp.
int 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 136 of file threadpool.hpp.
int FixedSize = ThreadPool::HardwareConcurrency() |
The number of threads to create (or decrease to). If Mode equals Fixed, this is used and all other parameters are ignored. If Mode equals Auto, this field is ignored and the other parameters are used.
Definition at line 117 of file threadpool.hpp.
Ticks::Duration 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 141 of file threadpool.hpp.
int IncreaseThreshold = 300 |
A threshold in percent that determines at which overload factor the number of threads are 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 129 of file threadpool.hpp.
Modes Mode =Modes::Auto |
The mode of operation.
Definition at line 112 of file threadpool.hpp.
int WorkersMax = ThreadPool::HardwareConcurrency() |
The maximum number of threads to create.
Definition at line 120 of file threadpool.hpp.
int WorkersMin = 0 |
The minimum number of threads to keep alive.
Definition at line 123 of file threadpool.hpp.
|
inlineprotected |
Calculates the target size, depending on the parameters set in this struct and the actual values passed.
currentWorkers | The number of threads currently in the pool. |
idleWorkers | The size of the subset of threads currently idle. |
load | The number of jobs currently queued. |
lastChangeTime | Time point of last increase or decrease. |
Definition at line 157 of file threadpool.hpp.