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

Value-semantic wrapper for a thread scheduling priority. More...

#include <scheduler_policy.hpp>

Public Member Functions

constexpr ThreadPriority (int priority=0)
constexpr auto value () const noexcept -> int
constexpr auto is_valid () const noexcept -> bool
constexpr auto operator== (ThreadPriority const &other) const noexcept -> bool
constexpr auto operator!= (ThreadPriority const &other) const noexcept -> bool
constexpr auto operator< (ThreadPriority const &other) const noexcept -> bool
constexpr auto operator<= (ThreadPriority const &other) const noexcept -> bool
constexpr auto operator> (ThreadPriority const &other) const noexcept -> bool
constexpr auto operator>= (ThreadPriority const &other) const noexcept -> bool
auto to_string () const -> std::string

Static Public Member Functions

static constexpr auto lowest () noexcept -> ThreadPriority
static constexpr auto normal () noexcept -> ThreadPriority
static constexpr auto highest () noexcept -> ThreadPriority

Detailed Description

Value-semantic wrapper for a thread scheduling priority.

Encapsulates a single integer priority in the range [-20, 19] - the same range used by POSIX nice values on Linux. The value is silently clamped to this range on construction (via std::clamp), so out-of-range inputs never produce an invalid object.

Semantics

Lower numeric values denote higher scheduling priority (following the Unix nice convention): -20 is the most favourable and 19 is the least.

Platform notes

  • Linux: The value is used directly as the nice level for SCHED_OTHER / SCHED_BATCH / SCHED_IDLE, or clamped to the real-time priority range for SCHED_FIFO / SCHED_RR by SchedulerParams::create_for_policy().
  • Windows: The value is mapped to a Windows thread priority constant (e.g. THREAD_PRIORITY_HIGHEST, THREAD_PRIORITY_LOWEST) when applied.

Type traits

  • Trivially copyable and trivially movable.
  • constexpr-constructible - can be used in compile-time contexts.
  • All relational operators (==, !=, <, <=, >, >=) are provided and compare the underlying integer value.
  • Not thread-safe: concurrent mutation of the same instance requires external synchronisation. Distinct instances may be used freely from different threads.
See also
SchedulerParams::create_for_policy

Definition at line 106 of file scheduler_policy.hpp.

Constructor & Destructor Documentation

◆ ThreadPriority()

threadschedule::ThreadPriority::ThreadPriority ( int priority = 0)
inlineexplicitconstexpr

Definition at line 109 of file scheduler_policy.hpp.

Member Function Documentation

◆ highest()

constexpr auto threadschedule::ThreadPriority::highest ( ) -> ThreadPriority
inlinestaticnodiscardconstexprnoexcept

Definition at line 130 of file scheduler_policy.hpp.

◆ is_valid()

auto threadschedule::ThreadPriority::is_valid ( ) const -> bool
inlinenodiscardconstexprnoexcept

Definition at line 117 of file scheduler_policy.hpp.

◆ lowest()

constexpr auto threadschedule::ThreadPriority::lowest ( ) -> ThreadPriority
inlinestaticnodiscardconstexprnoexcept

Definition at line 122 of file scheduler_policy.hpp.

◆ normal()

constexpr auto threadschedule::ThreadPriority::normal ( ) -> ThreadPriority
inlinestaticnodiscardconstexprnoexcept

Definition at line 126 of file scheduler_policy.hpp.

◆ operator!=()

auto threadschedule::ThreadPriority::operator!= ( ThreadPriority const & other) const -> bool
inlinenodiscardconstexprnoexcept

Definition at line 139 of file scheduler_policy.hpp.

◆ operator<()

auto threadschedule::ThreadPriority::operator< ( ThreadPriority const & other) const -> bool
inlinenodiscardconstexprnoexcept

Definition at line 143 of file scheduler_policy.hpp.

◆ operator<=()

auto threadschedule::ThreadPriority::operator<= ( ThreadPriority const & other) const -> bool
inlinenodiscardconstexprnoexcept

Definition at line 147 of file scheduler_policy.hpp.

◆ operator==()

auto threadschedule::ThreadPriority::operator== ( ThreadPriority const & other) const -> bool
inlinenodiscardconstexprnoexcept

Definition at line 135 of file scheduler_policy.hpp.

◆ operator>()

auto threadschedule::ThreadPriority::operator> ( ThreadPriority const & other) const -> bool
inlinenodiscardconstexprnoexcept

Definition at line 151 of file scheduler_policy.hpp.

◆ operator>=()

auto threadschedule::ThreadPriority::operator>= ( ThreadPriority const & other) const -> bool
inlinenodiscardconstexprnoexcept

Definition at line 155 of file scheduler_policy.hpp.

◆ to_string()

auto threadschedule::ThreadPriority::to_string ( ) const -> std::string
inlinenodiscard

Definition at line 160 of file scheduler_policy.hpp.

◆ value()

auto threadschedule::ThreadPriority::value ( ) const -> int
inlinenodiscardconstexprnoexcept

Definition at line 113 of file scheduler_policy.hpp.


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