33#if __cplusplus >= 202002L || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
117 if (!t.set_scheduling_policy(p.policy, p.priority).has_value())
119 if (p.affinity.has_value())
121 if (!t.set_affinity(*p.affinity).has_value())
126 return unexpected(std::make_error_code(std::errc::operation_not_permitted));
132template <
typename PoolType>
137 if (!pool.configure_threads(name_prefix, p.policy, p.priority).has_value())
139 if (p.affinity.has_value())
141 if (!pool.set_affinity(*p.affinity).has_value())
146 return unexpected(std::make_error_code(std::errc::operation_not_permitted));
159template <
typename ThreadLike, std::enable_if_t<is_thread_like_v<ThreadLike>,
int> = 0>
211 if (!reg.set_scheduling_policy(tid, p.policy, p.priority).has_value())
213 if (p.affinity.has_value())
215 if (!reg.set_affinity(tid, *p.affinity).has_value())
220 return unexpected(std::make_error_code(std::errc::operation_not_permitted));
Per-thread control handle for OS-level scheduling operations.
Value-semantic wrapper for a thread scheduling priority.
static constexpr auto normal() noexcept -> ThreadPriority
static constexpr auto highest() noexcept -> ThreadPriority
static constexpr auto lowest() noexcept -> ThreadPriority
Central registry of threads indexed by OS-level thread ID (Tid).
Non-owning view over an externally managed std::thread.
Owning wrapper around std::thread with RAII join-on-destroy semantics.
A result type that holds either a value of type T or an error of type E.
Exception thrown by expected::value() when the object is in the error state.
C++20 concepts, type traits, and SFINAE helpers for the threading library.
auto apply_profile_to(T &t, ThreadProfile const &p) -> expected< void, std::error_code >
Apply policy + optional affinity to any type exposing set_scheduling_policy() and set_affinity().
auto apply_profile_to_pool(PoolType &pool, std::string const &name_prefix, ThreadProfile const &p) -> expected< void, std::error_code >
Apply configure_threads + optional affinity to any pool type.
auto throughput() -> ThreadProfile
Throughput-oriented profile favoring batch scheduling.
auto background() -> ThreadProfile
Background profile for very low priority work.
auto low_latency() -> ThreadProfile
Low-latency interactive profile using RR scheduling.
auto realtime() -> ThreadProfile
Highest priority profile. Uses FIFO on Linux (if permitted), falls back to OTHER on Windows.
SchedulingPolicy
Enumeration of available thread scheduling policies.
@ OTHER
Standard round-robin time-sharing.
@ BATCH
For batch style execution.
@ IDLE
For very low priority background tasks.
@ FIFO
First in, first out.
ThreadPoolBase< IndefiniteWait > ThreadPool
General-purpose thread pool with indefinite blocking wait.
auto apply_profile(ThreadLike &t, ThreadProfile const &p) -> expected< void, std::error_code >
Apply a profile to a thread wrapper or view.
ThreadWrapperView JThreadWrapperView
ThreadPoolBase< PollingWait<> > FastThreadPool
Thread pool with 10 ms polling wait for lower wake-up latency.
ThreadWrapper JThreadWrapper
Owning wrapper around std::jthread with cooperative cancellation (C++20).
Scheduling policies, thread priority, and CPU affinity types.
Snapshot of metadata for a single registered thread.
Declarative profile bundling scheduling intent for a thread.
std::optional< ThreadAffinity > affinity
Type trait that identifies thread-like types.
Thread pools: HighPerformancePool, ThreadPoolBase, LightweightPoolT, and GlobalPool.
Process-wide thread registry, control blocks, and composite registry.