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

Configuration for priority aging behavior. More...

#include <priority_aging_config.h>

Collaboration diagram for kcenon::thread::priority_aging_config:
Collaboration graph

Public Attributes

bool enabled = false
 Whether priority aging is enabled.
 
std::chrono::milliseconds aging_interval {1000}
 Interval at which aging is applied.
 
int priority_boost_per_interval = 1
 Amount of priority boost applied per aging interval.
 
int max_priority_boost = 3
 Maximum total priority boost that can be applied.
 
aging_curve curve = aging_curve::linear
 The aging curve algorithm to use.
 
double exponential_factor = 1.5
 Exponential factor for exponential aging curve.
 
std::chrono::seconds starvation_threshold {30}
 Threshold for starvation detection.
 
std::function< void(const job_info &)> starvation_callback
 Callback function invoked when a job is starving.
 
bool reset_on_dequeue = true
 Whether to reset the boost when a job is dequeued.
 

Detailed Description

Configuration for priority aging behavior.

This structure contains all the parameters needed to configure priority aging in a typed thread pool. Priority aging prevents starvation of low-priority jobs by automatically boosting their priority based on wait time.

Example Usage

.enabled = true,
.aging_interval = std::chrono::seconds{1},
.priority_boost_per_interval = 1,
.max_priority_boost = 3,
};
@ linear
Constant boost per interval.
Configuration for priority aging behavior.

Definition at line 79 of file priority_aging_config.h.

Member Data Documentation

◆ aging_interval

std::chrono::milliseconds kcenon::thread::priority_aging_config::aging_interval {1000}

Interval at which aging is applied.

Jobs waiting longer than this interval will receive a priority boost.

Definition at line 93 of file priority_aging_config.h.

93{1000};

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

◆ curve

aging_curve kcenon::thread::priority_aging_config::curve = aging_curve::linear

The aging curve algorithm to use.

  • linear: Constant boost per interval
  • exponential: Increasing boost over time
  • logarithmic: Fast initial boost, slower over time

Definition at line 116 of file priority_aging_config.h.

◆ enabled

bool kcenon::thread::priority_aging_config::enabled = false

Whether priority aging is enabled.

When disabled, no priority boosting occurs.

Examples
config_example.cpp.

Definition at line 86 of file priority_aging_config.h.

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

◆ exponential_factor

double kcenon::thread::priority_aging_config::exponential_factor = 1.5

Exponential factor for exponential aging curve.

Only used when curve is set to exponential.

Definition at line 123 of file priority_aging_config.h.

◆ max_priority_boost

int kcenon::thread::priority_aging_config::max_priority_boost = 3

Maximum total priority boost that can be applied.

Prevents low-priority jobs from exceeding a certain priority level.

Definition at line 107 of file priority_aging_config.h.

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

◆ priority_boost_per_interval

int kcenon::thread::priority_aging_config::priority_boost_per_interval = 1

Amount of priority boost applied per aging interval.

Higher values result in faster priority escalation.

Definition at line 100 of file priority_aging_config.h.

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

◆ reset_on_dequeue

bool kcenon::thread::priority_aging_config::reset_on_dequeue = true

Whether to reset the boost when a job is dequeued.

When true, the priority boost is reset after the job is dequeued.

Definition at line 145 of file priority_aging_config.h.

◆ starvation_callback

std::function<void(const job_info&)> kcenon::thread::priority_aging_config::starvation_callback

Callback function invoked when a job is starving.

This callback is called when a job has been waiting longer than the starvation_threshold. Can be used for alerting or monitoring.

Definition at line 138 of file priority_aging_config.h.

◆ starvation_threshold

std::chrono::seconds kcenon::thread::priority_aging_config::starvation_threshold {30}

Threshold for starvation detection.

If a job waits longer than this threshold, it is considered starving.

Definition at line 130 of file priority_aging_config.h.

130{30};

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