ThreadSchedule 3.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
threadschedule::detail::scheduler_parameters Class Reference

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

#include <native.hpp>

Static Public Member Functions

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

Detailed Description

Static utility class for constructing OS-native scheduling parameters.

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

<tt>create_for_policy</tt>

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.

<tt>get_priority_range</tt>

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

Platform differences

  • Linux: Delegates to POSIX sched_get_priority_min / sched_get_priority_max. Positive priorities for real-time policies are used as native POSIX values; non-positive values are mapped from nice-style ordering into the native sched_param range.
  • Windows: Returns a fixed range of 30. Normal priorities use the safe nice-to-Win32 mapping, while realtime policies select only THREAD_PRIORITY_ABOVE_NORMAL or THREAD_PRIORITY_HIGHEST. The result is stored 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
native_scheduling_policy, native_thread_priority

Definition at line 650 of file native.hpp.

Member Function Documentation

◆ create_for_policy()

static auto threadschedule::detail::scheduler_parameters::create_for_policy ( native_scheduling_policy  policy,
native_thread_priority  priority 
) -> expected<sched_param, std::error_code>
inlinestatic

Definition at line 685 of file native.hpp.

References threadschedule::detail::is_realtime_policy().

◆ get_priority_range()

static auto threadschedule::detail::scheduler_parameters::get_priority_range ( native_scheduling_policy  policy) -> expected<int, std::error_code>
inlinestatic

Definition at line 726 of file native.hpp.


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