|
ThreadSchedule 2.0.0
Modern C++ thread management library
|
Polymorphic base providing common thread management operations. More...
#include <thread_wrapper.hpp>
Public Types | |
| using | native_handle_type = typename ThreadType::native_handle_type |
| using | id = typename ThreadType::id |
Public Member Functions | |
| BaseThreadWrapper ()=default | |
| BaseThreadWrapper (ThreadType &t) | |
| 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 | |
| static auto | set_nice_value (int nice_value) -> bool |
| static auto | get_nice_value () -> std::optional< int > |
Polymorphic base providing common thread management operations.
| ThreadType | The underlying thread type (std::thread or std::jthread). |
| OwnershipTag | detail::OwningTag (default) or detail::NonOwningTag. |
Provides a uniform interface for join, detach, naming, priority, affinity, scheduling policy, and nice-value control on top of any standard thread type. Derived classes (ThreadWrapper, JThreadWrapper, and their View counterparts) customize ownership semantics while inheriting all of these operations.
pthread_setname_np; names are limited to 15 characters (returns errc::invalid_argument if exceeded).SetThreadDescription from kernel32.dll. Names may be longer. Returns errc::function_not_supported if the API is unavailable (pre-Windows 10 1607).pthread_setschedparam and may require CAP_SYS_NICE or root privileges for real-time policies. On Windows, maps to SetThreadPriority constants.pthread_setaffinity_np with cpu_set_t.SetThreadGroupAffinity (multi-processor-group aware) and falls back to SetThreadAffinityMask on single-group systems.setpriority(PRIO_PROCESS, ...). On Windows maps to SetPriorityClass / GetPriorityClass.set_* methods (except set_nice_value) return expected<void, std::error_code>. Always check the return value; failures are silent unless inspected.Definition at line 168 of file thread_wrapper.hpp.
| using threadschedule::BaseThreadWrapper< ThreadType, OwnershipTag >::id = typename ThreadType::id |
Definition at line 172 of file thread_wrapper.hpp.
| using threadschedule::BaseThreadWrapper< ThreadType, OwnershipTag >::native_handle_type = typename ThreadType::native_handle_type |
Definition at line 171 of file thread_wrapper.hpp.
|
default |
Referenced by get_affinity(), and get_name().
|
inlineexplicit |
Definition at line 175 of file thread_wrapper.hpp.
|
virtualdefault |
|
inline |
Definition at line 189 of file thread_wrapper.hpp.
References joinable().
|
inlinenodiscard |
Definition at line 236 of file thread_wrapper.hpp.
References BaseThreadWrapper(), native_handle(), and threadschedule::detail::read_affinity().
|
inlinenodiscardnoexcept |
Definition at line 201 of file thread_wrapper.hpp.
|
inlinenodiscard |
Definition at line 215 of file thread_wrapper.hpp.
References BaseThreadWrapper(), native_handle(), and threadschedule::detail::read_name().
|
inlinestatic |
Definition at line 274 of file thread_wrapper.hpp.
|
inline |
Definition at line 181 of file thread_wrapper.hpp.
References joinable().
|
inlinenodiscardnoexcept |
Definition at line 197 of file thread_wrapper.hpp.
|
inlinenodiscardnoexcept |
Definition at line 205 of file thread_wrapper.hpp.
Referenced by get_affinity(), get_name(), set_affinity(), set_name(), set_priority(), and set_scheduling_policy().
|
inlinenodiscard |
Definition at line 231 of file thread_wrapper.hpp.
References threadschedule::detail::apply_affinity(), and native_handle().
|
inlinenodiscard |
Definition at line 210 of file thread_wrapper.hpp.
References threadschedule::detail::apply_name(), and native_handle().
Referenced by threadschedule::ThreadWrapper::create_with_config().
|
inlinestatic |
Definition at line 242 of file thread_wrapper.hpp.
|
inlinenodiscard |
Definition at line 220 of file thread_wrapper.hpp.
References threadschedule::detail::apply_priority(), and native_handle().
|
inlinenodiscard |
Definition at line 225 of file thread_wrapper.hpp.
References threadschedule::detail::apply_scheduling_policy(), and native_handle().
Referenced by threadschedule::ThreadWrapper::create_with_config().