|
ThreadSchedule 2.2.0
Modern C++ thread management library
|
Lightweight handle for querying and controlling a specific OS thread. More...
#include <thread_wrapper.hpp>
Public Types | |
| using | native_handle_type = pthread_t |
Public Member Functions | |
| ThreadInfo () | |
| ThreadInfo (Tid tid) | |
| auto | thread_id () const noexcept -> Tid |
| auto | set_name (std::string const &name) const -> expected< void, std::error_code > |
| auto | get_name () const -> std::optional< std::string > |
| auto | set_priority (ThreadPriority priority) const -> expected< void, std::error_code > |
| auto | set_scheduling_policy (SchedulingPolicy policy, ThreadPriority priority) const -> expected< void, std::error_code > |
| auto | set_affinity (ThreadAffinity const &affinity) const -> expected< void, std::error_code > |
| auto | get_affinity () const -> std::optional< ThreadAffinity > |
| auto | get_policy () const -> std::optional< SchedulingPolicy > |
| auto | get_priority () const -> std::optional< int > |
Static Public Member Functions | |
| static auto | hardware_concurrency () -> unsigned int |
| static auto | get_thread_id () -> Tid |
| static auto | get_current_policy () -> std::optional< SchedulingPolicy > |
| static auto | get_current_priority () -> std::optional< int > |
Lightweight handle for querying and controlling a specific OS thread.
The default constructor binds to the current thread. The explicit constructor binds to a caller-provided OS thread ID (Tid), allowing callers to act on library-owned background threads or any other live thread in the process.
hardware_concurrency() - delegates to std::thread::hardware_concurrency().get_thread_id() - returns the OS-level thread ID (Linux TID via syscall(SYS_gettid), Windows thread ID via GetCurrentThreadId()).set_name, get_name, set_priority, set_scheduling_policy, set_affinity, get_affinity, get_policy, and get_priority for the bound thread ID.get_current_policy() / get_current_priority() remain as compatibility conveniences for the current thread.Definition at line 826 of file thread_wrapper.hpp.
| using threadschedule::ThreadInfo::native_handle_type = pthread_t |
Definition at line 832 of file thread_wrapper.hpp.
|
inline |
Definition at line 835 of file thread_wrapper.hpp.
References get_thread_id().
Referenced by get_current_policy(), and get_current_priority().
|
inlineexplicit |
Definition at line 840 of file thread_wrapper.hpp.
|
inlinenodiscard |
Definition at line 885 of file thread_wrapper.hpp.
References threadschedule::detail::read_affinity().
|
inlinestatic |
Definition at line 920 of file thread_wrapper.hpp.
References ThreadInfo().
|
inlinestatic |
Definition at line 925 of file thread_wrapper.hpp.
References ThreadInfo().
|
inlinenodiscard |
Definition at line 856 of file thread_wrapper.hpp.
References threadschedule::detail::read_name().
|
inlinenodiscard |
Definition at line 892 of file thread_wrapper.hpp.
References threadschedule::detail::read_scheduling_policy().
|
inlinenodiscard |
Definition at line 899 of file thread_wrapper.hpp.
References threadschedule::detail::read_priority().
|
inlinestatic |
Definition at line 911 of file thread_wrapper.hpp.
Referenced by threadschedule::ChaosController::ChaosController(), threadschedule::ThreadControlBlock::create_for_current_thread(), threadschedule::ThreadRegistry::register_current_thread(), threadschedule::ScheduledThreadPoolT< ThreadPool >::ScheduledThreadPoolT(), ThreadInfo(), and threadschedule::ThreadRegistry::unregister_current_thread().
|
inlinestatic |
Definition at line 906 of file thread_wrapper.hpp.
|
inlinenodiscard |
Definition at line 878 of file thread_wrapper.hpp.
References threadschedule::detail::apply_affinity().
|
inlinenodiscard |
Definition at line 849 of file thread_wrapper.hpp.
References threadschedule::detail::apply_name().
Referenced by threadschedule::ChaosController::ChaosController(), and threadschedule::ScheduledThreadPoolT< ThreadPool >::ScheduledThreadPoolT().
|
inlinenodiscard |
Definition at line 863 of file thread_wrapper.hpp.
References threadschedule::detail::apply_priority().
|
inlinenodiscard |
Definition at line 870 of file thread_wrapper.hpp.
References threadschedule::detail::apply_scheduling_policy().
|
inlinenodiscardnoexcept |
Definition at line 844 of file thread_wrapper.hpp.