|
ThreadSchedule 2.2.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 57 of file pthread_wrapper.hpp.
| using threadschedule::PThreadWrapper::id = pthread_t |
Definition at line 61 of file pthread_wrapper.hpp.
| using threadschedule::PThreadWrapper::native_handle_type = pthread_t |
Definition at line 60 of file pthread_wrapper.hpp.
|
inline |
Definition at line 63 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 68 of file pthread_wrapper.hpp.
References threadschedule::detail::make_move_callable().
|
delete |
References PThreadWrapper().
|
inlinenoexcept |
Definition at line 90 of file pthread_wrapper.hpp.
References PThreadWrapper().
|
inline |
Definition at line 112 of file pthread_wrapper.hpp.
References join(), and joinable().
|
inlinenodiscard |
Definition at line 192 of file pthread_wrapper.hpp.
|
inlinestatic |
Definition at line 230 of file pthread_wrapper.hpp.
References threadschedule::detail::make_move_callable(), and PThreadWrapper().
|
inlinestatic |
Definition at line 219 of file pthread_wrapper.hpp.
References PThreadWrapper(), set_name(), and set_scheduling_policy().
|
inline |
Definition at line 134 of file pthread_wrapper.hpp.
References joinable().
|
inlinenodiscard |
Definition at line 186 of file pthread_wrapper.hpp.
References threadschedule::detail::read_affinity().
|
inlinenodiscard |
Definition at line 151 of file pthread_wrapper.hpp.
|
inlinenodiscard |
Definition at line 165 of file pthread_wrapper.hpp.
References threadschedule::detail::read_name().
|
inline |
Definition at line 121 of file pthread_wrapper.hpp.
References joinable().
Referenced by operator=(), and ~PThreadWrapper().
|
inlinenodiscard |
Definition at line 146 of file pthread_wrapper.hpp.
Referenced by detach(), join(), operator=(), and ~PThreadWrapper().
|
inlinenodiscard |
Definition at line 155 of file pthread_wrapper.hpp.
|
inlinenoexcept |
Definition at line 96 of file pthread_wrapper.hpp.
References join(), joinable(), and PThreadWrapper().
|
delete |
References PThreadWrapper().
|
inlinenodiscard |
Definition at line 181 of file pthread_wrapper.hpp.
References threadschedule::detail::apply_affinity().
|
inlinestatic |
Definition at line 199 of file pthread_wrapper.hpp.
|
inlinestatic |
Definition at line 208 of file pthread_wrapper.hpp.
|
inlinenodiscard |
Definition at line 160 of file pthread_wrapper.hpp.
References threadschedule::detail::apply_name().
Referenced by create_with_config().
|
inlinenodiscard |
Definition at line 170 of file pthread_wrapper.hpp.
References threadschedule::detail::apply_priority().
|
inlinenodiscard |
Definition at line 175 of file pthread_wrapper.hpp.
References threadschedule::detail::apply_scheduling_policy().
Referenced by create_with_config().