|
ThreadSchedule 3.0.0
Modern C++ thread management library
|
Owning thread wrapper with result-based lifecycle/configuration API. More...
#include <thread.hpp>
Public Member Functions | |
| thread ()=default | |
| Construct an empty, non-joinable thread object. | |
| thread (std::thread &&value) noexcept | |
| Take ownership of an existing std::thread. | |
| template<typename F , typename... Args, std::enable_if_t< !std::is_same_v< std::decay_t< F >, thread > &&!std::is_same_v< std::decay_t< F >, thread_config >, int > = 0> | |
| thread (F &&function, Args &&... args) | |
| Start a thread from callable and arguments. | |
| template<typename F , typename... Args> | |
| thread (thread_config const &config, F &&function, Args &&... args) | |
| Start a thread and apply thread_config before user code runs. | |
| thread (thread &&) noexcept=default | |
| auto | operator= (thread &&) noexcept -> thread &=default |
| thread (thread const &)=delete | |
| auto | operator= (thread const &) -> thread &=delete |
| auto | join () -> result< void > |
| Join the thread. | |
| void | join_or_throw () |
| Throwing counterpart to join. | |
| auto | detach () -> result< void > |
| Detach the thread. | |
| void | detach_or_throw () |
| Throwing counterpart to detach. | |
| auto | joinable () const noexcept -> bool |
| Return whether the thread object owns a running thread. | |
| auto | get_id () const noexcept -> std::thread::id |
| Return std::thread id of the owned thread. | |
| auto | configure (thread_config const &config) -> result< void > |
| Apply a full portable thread configuration to the running thread. | |
| auto | set_priority (priority_level level) -> result< void > |
| Set portable priority preset. | |
| auto | set_nice (nice_value value) -> result< void > |
| Set explicit nice value. | |
| auto | get_priority () const -> result< priority_level > |
| Query current portable priority preset. | |
| auto | get_nice () const -> result< nice_value > |
| Query current nice value. | |
| auto | set_name (std::string const &name) -> result< void > |
| Set thread name. | |
| auto | get_name () const -> result< std::string > |
| Query thread name if supported by platform/backend. | |
| auto | set_affinity (thread_affinity const &affinity) -> result< void > |
| Apply CPU affinity set. | |
| auto | get_affinity () const -> result< thread_affinity > |
| Query current CPU affinity. | |
| auto | release () noexcept -> std::thread |
| Release ownership and return underlying std::thread. | |
Static Public Member Functions | |
| template<typename F , typename... Args> | |
| static auto | create (F &&function, Args &&... args) -> std::enable_if_t<!std::is_same_v< std::decay_t< F >, thread_config >, result< thread > > |
| Create thread without throwing. | |
| template<typename F , typename... Args> | |
| static auto | create (thread_config const &config, F &&function, Args &&... args) -> result< thread > |
| Create configured thread without throwing. | |
| static auto | hardware_concurrency () noexcept -> unsigned |
| Forward std::thread::hardware_concurrency(). | |
Friends | |
| struct | detail::native_thread_access |
| class | thread_view |
Owning thread wrapper with result-based lifecycle/configuration API.
Definition at line 28 of file thread.hpp.
|
default |
|
inlineexplicitnoexcept |
Take ownership of an existing std::thread.
operation_not_supported because an external thread's kernel TID cannot be recovered portably. Definition at line 39 of file thread.hpp.
|
inlineexplicit |
Start a thread from callable and arguments.
| function | Callable entry point. |
| args | Arguments forwarded to function. |
Definition at line 48 of file thread.hpp.
|
inline |
Start a thread and apply thread_config before user code runs.
| config | Portable thread configuration. |
| function | Callable entry point. |
| args | Arguments forwarded to function. |
Definition at line 59 of file thread.hpp.
|
defaultnoexcept |
|
delete |
|
inline |
Apply a full portable thread configuration to the running thread.
Definition at line 148 of file thread.hpp.
Referenced by threadschedule::advanced::chaos_controller::configure_thread(), and threadschedule::detail::configure_thread().
|
inlinestatic |
Create thread without throwing.
| function | Callable entry point. |
| args | Arguments forwarded to function. |
Definition at line 76 of file thread.hpp.
References thread(), and threadschedule::detail::try_result().
|
inlinestatic |
Create configured thread without throwing.
| config | Portable thread configuration. |
| function | Callable entry point. |
| args | Arguments forwarded to function. |
Definition at line 91 of file thread.hpp.
References thread(), and threadschedule::detail::try_result().
|
inline |
Detach the thread.
Definition at line 113 of file thread.hpp.
|
inline |
Throwing counterpart to detach.
Definition at line 120 of file thread.hpp.
|
inline |
Query current CPU affinity.
Definition at line 204 of file thread.hpp.
References threadschedule::detail::basic_thread_backend< ThreadType, OwnershipTag >::get_affinity().
|
inlinenoexcept |
Return std::thread id of the owned thread.
Definition at line 134 of file thread.hpp.
References threadschedule::detail::basic_thread_backend< ThreadType, OwnershipTag >::get_id().
Referenced by threadschedule::advanced::chaos_controller::thread_info().
|
inline |
Query thread name if supported by platform/backend.
Definition at line 190 of file thread.hpp.
References threadschedule::detail::basic_thread_backend< ThreadType, OwnershipTag >::get_name().
Referenced by threadschedule::advanced::chaos_controller::thread_info().
|
inline |
Query current nice value.
Definition at line 176 of file thread.hpp.
References threadschedule::detail::basic_thread_backend< ThreadType, OwnershipTag >::get_nice_value().
|
inline |
Query current portable priority preset.
Definition at line 169 of file thread.hpp.
References threadschedule::detail::basic_thread_backend< ThreadType, OwnershipTag >::get_nice_value().
|
inlinestaticnoexcept |
Forward std::thread::hardware_concurrency().
Definition at line 141 of file thread.hpp.
|
inline |
Join the thread.
Definition at line 99 of file thread.hpp.
Referenced by threadschedule::advanced::chaos_controller::~chaos_controller().
|
inline |
Throwing counterpart to join.
Definition at line 106 of file thread.hpp.
|
inlinenoexcept |
Return whether the thread object owns a running thread.
Definition at line 127 of file thread.hpp.
References threadschedule::detail::basic_thread_backend< ThreadType, OwnershipTag >::joinable().
Referenced by threadschedule::advanced::chaos_controller::configure_thread(), threadschedule::advanced::chaos_controller::thread_info(), and threadschedule::advanced::chaos_controller::~chaos_controller().
|
inlinenoexcept |
Release ownership and return underlying std::thread.
Definition at line 211 of file thread.hpp.
References threadschedule::detail::thread_backend::release().
|
inline |
Apply CPU affinity set.
Definition at line 197 of file thread.hpp.
Referenced by threadschedule::detail::configure_thread().
|
inline |
Set thread name.
Definition at line 183 of file thread.hpp.
References threadschedule::detail::basic_thread_backend< ThreadType, OwnershipTag >::set_name().
Referenced by threadschedule::advanced::chaos_controller::chaos_controller(), threadschedule::detail::configure_thread(), and threadschedule::detail::configure_thread().
|
inline |
Set explicit nice value.
Definition at line 162 of file thread.hpp.
|
inline |
Set portable priority preset.
Definition at line 155 of file thread.hpp.
|
friend |
Definition at line 217 of file thread.hpp.
|
friend |
Definition at line 218 of file thread.hpp.