Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
Loading...
Searching...
No Matches
kcenon::thread::thread_system_config::pool_config Struct Reference

Configuration for thread pool behavior. More...

#include <thread_system_config.h>

Collaboration diagram for kcenon::thread::thread_system_config::pool_config:
Collaboration graph

Public Attributes

std::size_t worker_count = std::thread::hardware_concurrency()
 Number of worker threads in the pool.
 
std::size_t queue_capacity = 10000
 Maximum number of jobs in the queue.
 
backpressure_config backpressure {}
 Backpressure configuration.
 
std::chrono::milliseconds wake_interval {100}
 Wake interval for idle workers.
 
std::chrono::seconds shutdown_timeout {5}
 Shutdown timeout.
 
std::chrono::seconds worker_idle_timeout {30}
 Worker idle timeout.
 
bool yield_on_idle = true
 Yield on idle.
 
bool enable_work_stealing = false
 Enable work stealing.
 
std::size_t max_steal_attempts = 3
 Maximum steal attempts before backing off.
 
std::chrono::microseconds steal_backoff {50}
 Backoff duration between steal attempts.
 

Detailed Description

Configuration for thread pool behavior.

Definition at line 62 of file thread_system_config.h.

Member Data Documentation

◆ backpressure

backpressure_config kcenon::thread::thread_system_config::pool_config::backpressure {}

Backpressure configuration.

Controls how the queue handles overflow conditions. Default: blocking policy with 5s timeout

Examples
config_example.cpp.

Definition at line 85 of file thread_system_config.h.

85{};

Referenced by kcenon::thread::config_builder::enable_backpressure(), kcenon::thread::thread_system_config::is_valid(), kcenon::thread::config_builder::with_backpressure_policy(), and kcenon::thread::config_builder::with_watermarks().

◆ enable_work_stealing

bool kcenon::thread::thread_system_config::pool_config::enable_work_stealing = false

Enable work stealing.

When true, idle workers can steal jobs from busy workers. Default: false (can be enabled via THREAD_WORK_STEALING_ENABLED)

Definition at line 125 of file thread_system_config.h.

Referenced by kcenon::thread::config_builder::enable_work_stealing().

◆ max_steal_attempts

std::size_t kcenon::thread::thread_system_config::pool_config::max_steal_attempts = 3

Maximum steal attempts before backing off.

Only used when work stealing is enabled. Default: 3

Definition at line 133 of file thread_system_config.h.

Referenced by kcenon::thread::config_builder::with_work_stealing_params().

◆ queue_capacity

std::size_t kcenon::thread::thread_system_config::pool_config::queue_capacity = 10000

Maximum number of jobs in the queue.

Default: 10000 jobs Set to 0 for unlimited (not recommended for production)

Examples
config_example.cpp.

Definition at line 77 of file thread_system_config.h.

Referenced by kcenon::thread::config_builder::with_queue_capacity().

◆ shutdown_timeout

std::chrono::seconds kcenon::thread::thread_system_config::pool_config::shutdown_timeout {5}

Shutdown timeout.

Maximum time to wait for workers to complete during shutdown. Default: 5s

Definition at line 101 of file thread_system_config.h.

101{5};

◆ steal_backoff

std::chrono::microseconds kcenon::thread::thread_system_config::pool_config::steal_backoff {50}

Backoff duration between steal attempts.

Only used when work stealing is enabled. Default: 50μs

Definition at line 141 of file thread_system_config.h.

141{50};

Referenced by kcenon::thread::config_builder::with_work_stealing_params().

◆ wake_interval

std::chrono::milliseconds kcenon::thread::thread_system_config::pool_config::wake_interval {100}

Wake interval for idle workers.

How often idle workers check for new jobs. Default: 100ms

Definition at line 93 of file thread_system_config.h.

93{100};

◆ worker_count

std::size_t kcenon::thread::thread_system_config::pool_config::worker_count = std::thread::hardware_concurrency()

Number of worker threads in the pool.

Default: hardware_concurrency() (number of CPU cores)

Examples
config_example.cpp.

Definition at line 69 of file thread_system_config.h.

Referenced by kcenon::thread::thread_system_config::is_valid(), and kcenon::thread::config_builder::with_worker_count().

◆ worker_idle_timeout

std::chrono::seconds kcenon::thread::thread_system_config::pool_config::worker_idle_timeout {30}

Worker idle timeout.

Workers will be stopped after being idle for this duration. Default: 30s

Definition at line 109 of file thread_system_config.h.

109{30};

◆ yield_on_idle

bool kcenon::thread::thread_system_config::pool_config::yield_on_idle = true

Yield on idle.

When true, idle workers yield CPU to other threads. Default: true

Definition at line 117 of file thread_system_config.h.


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