ThreadSchedule 3.0.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) noexcept
 Create a view over an existing std::thread.
 
 thread_view (thread &value) 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) -> 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) -> result< void >
 Set viewed thread name.
 
auto get_name () const -> result< std::string >
 Query viewed thread name.
 
auto set_affinity (thread_affinity const &affinity) -> 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.

Definition at line 29 of file thread_view.hpp.

Constructor & Destructor Documentation

◆ thread_view() [1/2]

threadschedule::thread_view::thread_view ( std::thread &  value)
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 100 of file thread_view.hpp.

◆ thread_view() [2/2]

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

Create a view over a threadschedule::thread.

Definition at line 102 of file thread_view.hpp.

Member Function Documentation

◆ configure()

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

Apply full portable configuration to viewed thread.

Definition at line 121 of file thread_view.hpp.

◆ get_affinity()

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

Query viewed thread CPU affinity.

Definition at line 179 of file thread_view.hpp.

◆ get_id()

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

Return std::thread id of viewed thread.

Definition at line 114 of file thread_view.hpp.

◆ get_name()

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

Query viewed thread name.

Definition at line 165 of file thread_view.hpp.

◆ get_nice()

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

Query nice value of viewed thread.

Definition at line 150 of file thread_view.hpp.

◆ get_priority()

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

Query portable priority preset of viewed thread.

Definition at line 142 of file thread_view.hpp.

◆ joinable()

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

Return whether viewed thread is joinable.

Definition at line 107 of file thread_view.hpp.

◆ set_affinity()

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

Set viewed thread CPU affinity.

Definition at line 172 of file thread_view.hpp.

◆ set_name()

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

Set viewed thread name.

Definition at line 158 of file thread_view.hpp.

◆ set_nice()

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

Set explicit nice value on viewed thread.

Definition at line 135 of file thread_view.hpp.

◆ set_priority()

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

Set portable priority preset on viewed thread.

Definition at line 128 of file thread_view.hpp.


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