High-level presets to simplify configuring threads and pools without fiddling with low-level flags.
Presets
- realtime: Highest priority (Linux: FIFO if permitted; Windows: OTHER fallback), for hard real-time workloads.
- low_latency: Round-robin policy with elevated priority for responsiveness.
- throughput: Batch scheduling for bulk processing.
- background: Lowest priority for background tasks.
API
Header: include/threadschedule/profiles.hpp
using namespace threadschedule;
auto tid = ThreadInfo::get_thread_id();
Simple thread pool for general-purpose use.
Enhanced std::thread wrapper.
auto apply_profile(ThreadLike &t, ThreadProfile const &p) -> expected< void, std::error_code >
Apply a profile to a single thread wrapper or view.
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.
Modern C++23 Thread Scheduling Library.
Optional Affinity in Profiles
You can embed a ThreadAffinity into a profile to pin threads:
Declarative profile describing desired scheduling.
Notes
- Setting RT policies/priorities may require elevated capabilities (Linux: CAP_SYS_NICE).
- On Windows, policies map to priority; RT policies fall back to normal priority control.