ThreadSchedule 1.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
Thread Profiles

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;
// Single thread
ThreadWrapper t([]{ /* work */ });
// ThreadPool
ThreadPool pool(8);
// HighPerformancePool
// Registry-managed thread by Tid
auto tid = ThreadInfo::get_thread_id();
apply_profile(registry(), tid, profiles::background());
High-performance thread pool optimized for high-frequency task submission.
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.
Definition profiles.hpp:80
auto throughput() -> ThreadProfile
Throughput-oriented profile favoring batch scheduling.
Definition profiles.hpp:62
auto background() -> ThreadProfile
Background profile for very low priority work.
Definition profiles.hpp:70
auto low_latency() -> ThreadProfile
Low-latency interactive profile using RR scheduling.
Definition profiles.hpp:54
auto realtime() -> ThreadProfile
Highest priority profile. Uses FIFO on Linux (if permitted), falls back to OTHER on Windows.
Definition profiles.hpp:40
Modern C++23 Thread Scheduling Library.

Optional Affinity in Profiles

You can embed a ThreadAffinity into a profile to pin threads:

p.affinity = ThreadAffinity({0,1});
apply_profile(pool, p);
Declarative profile describing desired scheduling.
Definition profiles.hpp:27

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.