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

Non-owning view over a running thread or jthread. More...

#include <thread_view.hpp>

Public Member Functions

 thread_view (std::thread &value THREADSCHEDULE_LIFETIMEBOUND) noexcept
 Create a view over an existing std::thread.
 thread_view (thread &value THREADSCHEDULE_LIFETIMEBOUND) noexcept
 Create a view over a threadschedule::thread.
auto joinable () const noexcept -> bool
 Return whether viewed thread is joinable.
auto get_id () const noexcept -> std::thread::id
 Return std::thread id of viewed thread.
auto configure (thread_config const &config THREADSCHEDULE_NOESCAPE) -> result< void >
 Apply full portable configuration to viewed thread.
auto set_priority (priority_level level) -> result< void >
 Set portable priority preset on viewed thread.
auto set_nice (nice_value value) -> result< void >
 Set explicit nice value on viewed thread.
auto get_priority () const -> result< priority_level >
 Query portable priority preset of viewed thread.
auto get_nice () const -> result< nice_value >
 Query nice value of viewed thread.
auto set_name (std::string const &name THREADSCHEDULE_NOESCAPE) -> result< void >
 Set viewed thread name.
auto get_name () const -> result< std::string >
 Query viewed thread name.
auto set_affinity (thread_affinity const &affinity THREADSCHEDULE_NOESCAPE) -> result< void >
 Set viewed thread CPU affinity.
auto get_affinity () const -> result< thread_affinity >
 Query viewed thread CPU affinity.

Detailed Description

Non-owning view over a running thread or jthread.

This class never joins/detaches and only forwards control/query operations. The referenced C++ thread object must outlive the view. Configuration inputs are consumed synchronously and are not retained by the view.

Definition at line 32 of file thread_view.hpp.

Constructor & Destructor Documentation

◆ thread_view() [1/2]

threadschedule::thread_view::thread_view ( std::thread &value THREADSCHEDULE_LIFETIMEBOUND)
inlineexplicitnoexcept

Create a view over an existing std::thread.

Note
On Linux, nice control reports operation_not_supported because an external thread's kernel TID cannot be recovered portably.

Definition at line 110 of file thread_view.hpp.

References THREADSCHEDULE_LIFETIMEBOUND.

◆ thread_view() [2/2]

threadschedule::thread_view::thread_view ( thread &value THREADSCHEDULE_LIFETIMEBOUND)
inlineexplicitnoexcept

Create a view over a threadschedule::thread.

Definition at line 112 of file thread_view.hpp.

References THREADSCHEDULE_LIFETIMEBOUND.

Member Function Documentation

◆ configure()

auto threadschedule::thread_view::configure ( thread_config const &config THREADSCHEDULE_NOESCAPE) ->result< void >
inline

Apply full portable configuration to viewed thread.

Definition at line 134 of file thread_view.hpp.

References threadschedule::detail::portable_thread_control::configure(), and THREADSCHEDULE_NOESCAPE.

◆ get_affinity()

auto threadschedule::thread_view::get_affinity ( ) const->result< thread_affinity >
inlinenodiscard

Query viewed thread CPU affinity.

Definition at line 192 of file thread_view.hpp.

References threadschedule::detail::portable_thread_control::get_affinity().

◆ get_id()

auto threadschedule::thread_view::get_id ( ) const->std::thread::id
inlinenodiscardnoexcept

Return std::thread id of viewed thread.

Definition at line 127 of file thread_view.hpp.

◆ get_name()

auto threadschedule::thread_view::get_name ( ) const->result< std::string >
inlinenodiscard

Query viewed thread name.

Definition at line 178 of file thread_view.hpp.

◆ get_nice()

auto threadschedule::thread_view::get_nice ( ) const->result< nice_value >
inlinenodiscard

Query nice value of viewed thread.

Definition at line 163 of file thread_view.hpp.

References threadschedule::detail::portable_thread_control::get_nice().

◆ get_priority()

auto threadschedule::thread_view::get_priority ( ) const->result< priority_level >
inlinenodiscard

Query portable priority preset of viewed thread.

Definition at line 155 of file thread_view.hpp.

References threadschedule::detail::portable_thread_control::get_priority().

◆ joinable()

auto threadschedule::thread_view::joinable ( ) const->bool
inlinenodiscardnoexcept

Return whether viewed thread is joinable.

Definition at line 120 of file thread_view.hpp.

◆ set_affinity()

auto threadschedule::thread_view::set_affinity ( thread_affinity const &affinity THREADSCHEDULE_NOESCAPE) ->result< void >
inline

Set viewed thread CPU affinity.

Definition at line 185 of file thread_view.hpp.

References threadschedule::detail::portable_thread_control::set_affinity(), and THREADSCHEDULE_NOESCAPE.

◆ set_name()

auto threadschedule::thread_view::set_name ( std::string const &name THREADSCHEDULE_NOESCAPE) ->result< void >
inline

Set viewed thread name.

Definition at line 171 of file thread_view.hpp.

References THREADSCHEDULE_NOESCAPE.

◆ set_nice()

auto threadschedule::thread_view::set_nice ( nice_value value) ->result< void >
inline

Set explicit nice value on viewed thread.

Definition at line 148 of file thread_view.hpp.

References threadschedule::detail::portable_thread_control::set_nice().

◆ set_priority()

auto threadschedule::thread_view::set_priority ( priority_level level) ->result< void >
inline

Set portable priority preset on viewed thread.

Definition at line 141 of file thread_view.hpp.

References threadschedule::detail::portable_thread_control::set_priority().


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