template<typename ThreadType, typename OwnershipTag = detail::OwningTag>
class threadschedule::BaseThreadWrapper< ThreadType, OwnershipTag >
Polymorphic base providing common thread management operations.
- Template Parameters
-
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.
- Virtual Destructor
- Has a virtual destructor so it can be used as a polymorphic base.
- join() / detach()
- Both are safe to call even if the thread is not joinable (they check first).
- set_name()
- Linux: uses
pthread_setname_np; names are limited to 15 characters (returns errc::invalid_argument if exceeded).
- Windows: dynamically loads
SetThreadDescription from kernel32.dll. Names may be longer. Returns errc::function_not_supported if the API is unavailable (pre-Windows 10 1607).
- set_priority()
- Maps through SchedulerParams::create_for_policy(). On Linux, uses
pthread_setschedparam and may require CAP_SYS_NICE or root privileges for real-time policies. On Windows, maps to SetThreadPriority constants.
- set_scheduling_policy()
- Linux-specific concept; on Windows this falls back to set_priority().
- set_affinity()
- Linux:
pthread_setaffinity_np with cpu_set_t.
- Windows: prefers
SetThreadGroupAffinity (multi-processor-group aware) and falls back to SetThreadAffinityMask on single-group systems.
- set_nice_value() / get_nice_value()
- Process-level operation - affects all threads in the process. On Linux calls
setpriority(PRIO_PROCESS, ...). On Windows maps to SetPriorityClass / GetPriorityClass.
- Return Values
- All
set_* methods (except set_nice_value) return expected<void, std::error_code>. Always check the return value; failures are silent unless inspected.
- Thread Safety
- Individual method calls are safe if the underlying OS call is safe, but concurrent mutation of the same wrapper from multiple threads is not synchronized internally.
Definition at line 163 of file thread_wrapper.hpp.