ThreadSchedule 1.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
threadschedule::SchedulerParams Class Reference

Static utility class for constructing OS-native scheduling parameters. More...

#include <scheduler_policy.hpp>

Static Public Member Functions

static auto create_for_policy (SchedulingPolicy policy, ThreadPriority priority) -> expected< sched_param, std::error_code >
static auto get_priority_range (SchedulingPolicy policy) -> expected< int, std::error_code >

Detailed Description

Static utility class for constructing OS-native scheduling parameters.

SchedulerParams translates the portable SchedulingPolicy and ThreadPriority types into the platform-specific structures required by the OS scheduling APIs (sched_param on Linux, a compatible POD on Windows).

create_for_policy

Builds a native scheduling-parameter structure for a given policy/priority pair. The priority is clamped to the valid range for the requested policy (queried at runtime on Linux via sched_get_priority_min / sched_get_priority_max), so callers never need to pre-validate the range themselves. Returns an expected - on failure (e.g. an unrecognised policy value) an std::error_code is returned instead.

get_priority_range

Returns the width of the valid priority range (max - min) for a policy. Useful for normalising priorities across policies.

Platform differences

  • Linux: Delegates directly to POSIX sched_get_priority_min / sched_get_priority_max and populates a sched_param.
  • Windows: Returns a fixed range of 30 (mapping to the -15 ... +15 Windows thread priority levels) and stores the raw priority in a lightweight sched_param_win POD.

Thread safety

All members are static and stateless; concurrent calls from any number of threads are safe.

Note
This class is not intended to be instantiated.
See also
SchedulingPolicy, ThreadPriority

Definition at line 400 of file scheduler_policy.hpp.

Member Function Documentation

◆ create_for_policy()

auto threadschedule::SchedulerParams::create_for_policy ( SchedulingPolicy policy,
ThreadPriority priority ) -> expected<sched_param, std::error_code>
inlinestatic

Definition at line 425 of file scheduler_policy.hpp.

◆ get_priority_range()

auto threadschedule::SchedulerParams::get_priority_range ( SchedulingPolicy policy) -> expected<int, std::error_code>
inlinestatic

Definition at line 443 of file scheduler_policy.hpp.


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