|
ThreadSchedule 2.0.0
Modern C++ thread management library
|
RAII wrapper around POSIX threads with a modern C++ interface. More...
#include <pthread_wrapper.hpp>
Public Types | |
| using | native_handle_type = pthread_t |
| using | id = pthread_t |
Public Member Functions | |
| PThreadWrapper () | |
| template<typename F, typename... Args> | |
| PThreadWrapper (F &&func, Args &&... args) | |
| PThreadWrapper (PThreadWrapper const &)=delete | |
| auto | operator= (PThreadWrapper const &) -> PThreadWrapper &=delete |
| PThreadWrapper (PThreadWrapper &&other) noexcept | |
| auto | operator= (PThreadWrapper &&other) noexcept -> PThreadWrapper & |
| ~PThreadWrapper () | |
| void | join () |
| void | detach () |
| auto | joinable () const -> bool |
| auto | get_id () const -> id |
| auto | native_handle () const -> native_handle_type |
| 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 | cancel () const -> expected< void, std::error_code > |
Static Public Member Functions | |
| static auto | set_cancel_state (bool enabled) -> expected< void, std::error_code > |
| static auto | set_cancel_type (bool asynchronous) -> expected< void, std::error_code > |
| template<typename F, typename... Args> | |
| static auto | create_with_config (std::string const &name, SchedulingPolicy policy, ThreadPriority priority, F &&f, Args &&... args) -> PThreadWrapper |
| template<typename F, typename... Args> | |
| static auto | create_with_attributes (pthread_attr_t const &attr, F &&func, Args &&... args) -> PThreadWrapper |
RAII wrapper around POSIX threads with a modern C++ interface.
Linux-only - not available on Windows (guarded by _WIN32).
Non-copyable, movable. The destructor automatically joins the thread if it is still joinable, which blocks until the thread finishes.
Internally stores the callable in a heap-allocated std::function so that it can be passed through the C pthread_create API.
pthread_setname_np). static and affect the calling thread, not the PThreadWrapper's thread.pthread_attr_t.true_type at end of file) Definition at line 54 of file pthread_wrapper.hpp.
| using threadschedule::PThreadWrapper::id = pthread_t |
Definition at line 58 of file pthread_wrapper.hpp.
| using threadschedule::PThreadWrapper::native_handle_type = pthread_t |
Definition at line 57 of file pthread_wrapper.hpp.
|
inline |
Definition at line 60 of file pthread_wrapper.hpp.
Referenced by create_with_attributes(), create_with_config(), operator=(), operator=(), PThreadWrapper(), PThreadWrapper(), and threadschedule::PThreadWrapperReg::PThreadWrapperReg().
|
inlineexplicit |
Definition at line 65 of file pthread_wrapper.hpp.
|
delete |
References PThreadWrapper().
|
inlinenoexcept |
Definition at line 87 of file pthread_wrapper.hpp.
References PThreadWrapper().
|
inline |
Definition at line 109 of file pthread_wrapper.hpp.
References join(), and joinable().
|
inlinenodiscard |
Definition at line 189 of file pthread_wrapper.hpp.
|
inlinestatic |
Definition at line 227 of file pthread_wrapper.hpp.
References PThreadWrapper().
|
inlinestatic |
Definition at line 216 of file pthread_wrapper.hpp.
References PThreadWrapper(), set_name(), and set_scheduling_policy().
|
inline |
Definition at line 131 of file pthread_wrapper.hpp.
References joinable().
|
inlinenodiscard |
Definition at line 183 of file pthread_wrapper.hpp.
References threadschedule::detail::read_affinity().
|
inlinenodiscard |
Definition at line 148 of file pthread_wrapper.hpp.
|
inlinenodiscard |
Definition at line 162 of file pthread_wrapper.hpp.
References threadschedule::detail::read_name().
|
inline |
Definition at line 118 of file pthread_wrapper.hpp.
References joinable().
Referenced by operator=(), and ~PThreadWrapper().
|
inlinenodiscard |
Definition at line 143 of file pthread_wrapper.hpp.
Referenced by detach(), join(), operator=(), and ~PThreadWrapper().
|
inlinenodiscard |
Definition at line 152 of file pthread_wrapper.hpp.
|
inlinenoexcept |
Definition at line 93 of file pthread_wrapper.hpp.
References join(), joinable(), and PThreadWrapper().
|
delete |
References PThreadWrapper().
|
inlinenodiscard |
Definition at line 178 of file pthread_wrapper.hpp.
References threadschedule::detail::apply_affinity().
|
inlinestatic |
Definition at line 196 of file pthread_wrapper.hpp.
|
inlinestatic |
Definition at line 205 of file pthread_wrapper.hpp.
|
inlinenodiscard |
Definition at line 157 of file pthread_wrapper.hpp.
References threadschedule::detail::apply_name().
Referenced by create_with_config().
|
inlinenodiscard |
Definition at line 167 of file pthread_wrapper.hpp.
References threadschedule::detail::apply_priority().
|
inlinenodiscard |
Definition at line 172 of file pthread_wrapper.hpp.
References threadschedule::detail::apply_scheduling_policy().
Referenced by create_with_config().