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

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

#include <native.hpp>

Public Member Functions

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

Static Public Member Functions

static constexpr auto lowest () noexcept -> native_thread_priority
 
static constexpr auto normal () noexcept -> native_thread_priority
 
static constexpr auto highest () noexcept -> native_thread_priority
 
static constexpr auto realtime_lowest () noexcept -> native_thread_priority
 
static constexpr auto realtime_highest () noexcept -> native_thread_priority
 

Detailed Description

Value-semantic wrapper for a thread scheduling priority.

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

Semantics

For regular scheduling, lower numeric values denote higher scheduling priority (following the Unix nice convention): -20 is the most favourable and 19 is the least. For POSIX real-time policies (FIFO / RR), positive values are treated as native real-time priorities where larger values mean higher priority (typically 1..99 on Linux).

Platform notes

  • Linux: The value follows nice-level ordering for regular scheduling. For real-time policies, scheduler_parameters::create_for_policy() accepts native positive real-time priorities directly and maps non-positive nice-style values into the native POSIX priority range.
  • 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
scheduler_parameters::create_for_policy

Definition at line 139 of file native.hpp.

Constructor & Destructor Documentation

◆ native_thread_priority()

constexpr threadschedule::detail::native_thread_priority::native_thread_priority ( int  priority = 0)
inlineexplicitconstexpr

Definition at line 142 of file native.hpp.

Member Function Documentation

◆ highest()

static constexpr auto threadschedule::detail::native_thread_priority::highest ( ) -> native_thread_priority
inlinestaticconstexprnoexcept

◆ is_valid()

constexpr auto threadschedule::detail::native_thread_priority::is_valid ( ) const -> bool
inlineconstexprnoexcept

Definition at line 153 of file native.hpp.

◆ lowest()

static constexpr auto threadschedule::detail::native_thread_priority::lowest ( ) -> native_thread_priority
inlinestaticconstexprnoexcept

◆ normal()

static constexpr auto threadschedule::detail::native_thread_priority::normal ( ) -> native_thread_priority
inlinestaticconstexprnoexcept

◆ operator!=()

constexpr auto threadschedule::detail::native_thread_priority::operator!= ( native_thread_priority const &  other) const -> bool
inlineconstexprnoexcept

Definition at line 190 of file native.hpp.

References threadschedule::detail::other.

◆ operator<()

constexpr auto threadschedule::detail::native_thread_priority::operator< ( native_thread_priority const &  other) const -> bool
inlineconstexprnoexcept

Definition at line 194 of file native.hpp.

References threadschedule::detail::other.

◆ operator<=()

constexpr auto threadschedule::detail::native_thread_priority::operator<= ( native_thread_priority const &  other) const -> bool
inlineconstexprnoexcept

Definition at line 199 of file native.hpp.

References threadschedule::detail::other.

◆ operator==()

constexpr auto threadschedule::detail::native_thread_priority::operator== ( native_thread_priority const &  other) const -> bool
inlineconstexprnoexcept

Definition at line 185 of file native.hpp.

References threadschedule::detail::other.

◆ operator>()

constexpr auto threadschedule::detail::native_thread_priority::operator> ( native_thread_priority const &  other) const -> bool
inlineconstexprnoexcept

Definition at line 205 of file native.hpp.

References threadschedule::detail::other.

◆ operator>=()

constexpr auto threadschedule::detail::native_thread_priority::operator>= ( native_thread_priority const &  other) const -> bool
inlineconstexprnoexcept

Definition at line 210 of file native.hpp.

References threadschedule::detail::other.

◆ realtime_highest()

static constexpr auto threadschedule::detail::native_thread_priority::realtime_highest ( ) -> native_thread_priority
inlinestaticconstexprnoexcept

Definition at line 179 of file native.hpp.

◆ realtime_lowest()

static constexpr auto threadschedule::detail::native_thread_priority::realtime_lowest ( ) -> native_thread_priority
inlinestaticconstexprnoexcept

Definition at line 174 of file native.hpp.

◆ to_string()

auto threadschedule::detail::native_thread_priority::to_string ( ) const -> std::string
inline

Definition at line 216 of file native.hpp.

◆ value()

constexpr auto threadschedule::detail::native_thread_priority::value ( ) const -> int
inlineconstexprnoexcept

Definition at line 148 of file native.hpp.


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