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

Validated CPU identifier. More...

#include <cpu_id.hpp>

Public Member Functions

constexpr cpu_id (int value)
 Construct a CPU id and throw on invalid input.
constexpr auto value () const noexcept -> std::uint32_t
 Return the underlying CPU index.

Static Public Member Functions

static auto create (int value) noexcept -> result< cpu_id >
 Construct a CPU id without exceptions.

Friends

constexpr auto operator== (cpu_id lhs, cpu_id rhs) noexcept -> bool
constexpr auto operator!= (cpu_id lhs, cpu_id rhs) noexcept -> bool
constexpr auto operator< (cpu_id lhs, cpu_id rhs) noexcept -> bool

Detailed Description

Validated CPU identifier.

This type guarantees a non-negative CPU index and is used by thread_affinity to avoid accidental mixing with unrelated integers.

Definition at line 22 of file cpu_id.hpp.

Constructor & Destructor Documentation

◆ cpu_id()

threadschedule::cpu_id::cpu_id ( int value)
inlineexplicitconstexpr

Construct a CPU id and throw on invalid input.

Parameters
valueCPU index, must be >= 0.
Exceptions
std::invalid_argumentif value is negative.

Definition at line 30 of file cpu_id.hpp.

References value().

Referenced by create(), operator!=, operator<, and operator==.

Member Function Documentation

◆ create()

auto threadschedule::cpu_id::create ( int value) ->result< cpu_id >
inlinestaticnodiscardnoexcept

Construct a CPU id without exceptions.

Parameters
valueCPU index, must be >= 0.
Returns
A valid cpu_id or errc::invalid_argument.

Definition at line 38 of file cpu_id.hpp.

References cpu_id(), threadschedule::unexpected(), and value().

◆ value()

auto threadschedule::cpu_id::value ( ) const->std::uint32_t
inlinenodiscardconstexprnoexcept

Return the underlying CPU index.

Definition at line 47 of file cpu_id.hpp.

Referenced by cpu_id(), and create().

◆ operator!=

auto operator!= ( cpu_id lhs,
cpu_id rhs )->bool
friend

Definition at line 58 of file cpu_id.hpp.

References cpu_id().

◆ operator<

auto operator< ( cpu_id lhs,
cpu_id rhs )->bool
friend

Definition at line 62 of file cpu_id.hpp.

References cpu_id().

◆ operator==

auto operator== ( cpu_id lhs,
cpu_id rhs )->bool
friend

Definition at line 53 of file cpu_id.hpp.

References cpu_id().


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