|
ThreadSchedule 2.0.0
Modern C++ thread management library
|
Owning wrapper around std::thread with RAII join-on-destroy semantics. More...
#include <thread_wrapper.hpp>
Public Member Functions | |
| ThreadWrapper ()=default | |
| ThreadWrapper (std::thread &&t) noexcept | |
| template<typename F, typename... Args> | |
| ThreadWrapper (F &&f, Args &&... args) | |
| ThreadWrapper (ThreadWrapper const &)=delete | |
| auto | operator= (ThreadWrapper const &) -> ThreadWrapper &=delete |
| ThreadWrapper (ThreadWrapper &&other) noexcept | |
| auto | operator= (ThreadWrapper &&other) noexcept -> ThreadWrapper & |
| ~ThreadWrapper () override | |
| auto | release () noexcept -> std::thread |
| operator std::thread () &&noexcept | |
| Public Member Functions inherited from threadschedule::BaseThreadWrapper< std::thread, detail::OwningTag > | |
| BaseThreadWrapper ()=default | |
| virtual | ~BaseThreadWrapper ()=default |
| void | join () |
| void | detach () |
| auto | joinable () const noexcept -> bool |
| auto | get_id () const noexcept -> id |
| auto | native_handle () noexcept -> native_handle_type |
| auto | set_name (std::string const &name) -> expected< void, std::error_code > |
| auto | get_name () const -> std::optional< std::string > |
| auto | set_priority (ThreadPriority priority) -> expected< void, std::error_code > |
| auto | set_scheduling_policy (SchedulingPolicy policy, ThreadPriority priority) -> expected< void, std::error_code > |
| auto | set_affinity (ThreadAffinity const &affinity) -> expected< void, std::error_code > |
| auto | get_affinity () const -> std::optional< ThreadAffinity > |
Static Public Member Functions | |
| template<typename F, typename... Args> | |
| static auto | create_with_config (std::string const &name, SchedulingPolicy policy, ThreadPriority priority, F &&f, Args &&... args) -> ThreadWrapper |
| Static Public Member Functions inherited from threadschedule::BaseThreadWrapper< std::thread, detail::OwningTag > | |
| static auto | set_nice_value (int nice_value) -> bool |
| static auto | get_nice_value () -> std::optional< int > |
Additional Inherited Members | |
| Public Types inherited from threadschedule::BaseThreadWrapper< std::thread, detail::OwningTag > | |
| using | native_handle_type |
| using | id |
Owning wrapper around std::thread with RAII join-on-destroy semantics.
Extends BaseThreadWrapper to provide an owning, movable, non-copyable wrapper over std::thread. Adds automatic lifetime management: the destructor joins the thread if it is still joinable, which means destruction can block until the thread finishes.
join() if the thread is joinable. This will block the destroying thread until the managed thread completes. If blocking destruction is undesirable, call detach() or release() before the wrapper goes out of scope.std::thread out of the wrapper, returning it by value. After release, the wrapper holds a default-constructed (non-joinable) thread and destruction becomes a no-op.set_name() or set_scheduling_policy() are silently ignored - the thread will still be running but may not have the requested attributes. Check attributes after construction if they are critical.Definition at line 352 of file thread_wrapper.hpp.
|
default |
|
inlinenoexcept |
Definition at line 358 of file thread_wrapper.hpp.
|
inlineexplicit |
Definition at line 364 of file thread_wrapper.hpp.
References threadschedule::BaseThreadWrapper< std::thread, detail::OwningTag >::BaseThreadWrapper().
|
delete |
References ThreadWrapper().
|
inlinenoexcept |
Definition at line 372 of file thread_wrapper.hpp.
References ThreadWrapper().
|
inlineoverride |
Definition at line 390 of file thread_wrapper.hpp.
References threadschedule::BaseThreadWrapper< std::thread, detail::OwningTag >::joinable().
|
inlinestatic |
Definition at line 411 of file thread_wrapper.hpp.
References threadschedule::BaseThreadWrapper< ThreadType, OwnershipTag >::set_name(), threadschedule::BaseThreadWrapper< ThreadType, OwnershipTag >::set_scheduling_policy(), and ThreadWrapper().
|
inlineexplicitnoexcept |
Definition at line 404 of file thread_wrapper.hpp.
Referenced by release().
|
inlinenoexcept |
Definition at line 377 of file thread_wrapper.hpp.
References threadschedule::BaseThreadWrapper< std::thread, detail::OwningTag >::joinable(), and ThreadWrapper().
|
delete |
References ThreadWrapper().
|
inlinenoexcept |
Definition at line 399 of file thread_wrapper.hpp.
References operator std::thread().