Schedulers¶
Lazy pool¶
-
class lazy_pool¶
A scheduler based on a An Efficient Work-Stealing Scheduler for Task Dependency Graph
This pool sleeps workers which cannot find any work, as such it should be the default choice for most use cases. Additionally (if an installation of
hwloc
was found) this pool is NUMA aware.Note: The
lazy_pool
must not be destructed until all submitted tasks have reached a point where they will submit no-more work to the pool.Public Functions
-
inline explicit lazy_pool(std::size_t n = std::thread::hardware_concurrency(), numa_strategy strategy = numa_strategy::fan)¶
Construct a new lazy_pool object and
n
worker threads.- Parameters:
n – The number of worker threads to create, defaults to the number of hardware threads.
strategy – The numa strategy for distributing workers.
-
inline ~lazy_pool() noexcept¶
Destroy the lazy pool object, stops all workers.
-
inline auto contexts() noexcept -> std::span<worker_context*>¶
Get a view of the worker’s contexts.
-
auto operator=(lazy_pool const &other) -> lazy_pool& = delete¶
The lazy pool is not copy assignable.
-
inline void schedule(submit_handle job)¶
Schedule a job on a random worker.
-
inline explicit lazy_pool(std::size_t n = std::thread::hardware_concurrency(), numa_strategy strategy = numa_strategy::fan)¶
Busy pool¶
-
class busy_pool¶
A scheduler based on a traditional work-stealing thread pool.
Worker threads continuously try to steal tasks from other worker threads hence, they waste CPU cycles if sufficient work is not available. This is a good choice if the number of threads is equal to the number of hardware cores and the multiplexer has no other load. Additionally (if an installation of
hwloc
was found) this pool is NUMA aware.Note: The
busy_pool
must not be destructed until all submitted tasks have reached a point where they will submit no-more work to the pool.Public Functions
-
inline explicit busy_pool(std::size_t n = std::thread::hardware_concurrency(), numa_strategy strategy = numa_strategy::fan)¶
Construct a new busy_pool object.
- Parameters:
n – The number of worker threads to create, defaults to the number of hardware threads.
strategy – The numa strategy for distributing workers.
-
inline auto contexts() noexcept -> std::span<worker_context*>¶
Get a view of the worker’s contexts.
-
auto operator=(busy_pool const &other) -> busy_pool& = delete¶
The busy pool is not copy assignable.
-
inline void schedule(submit_handle job)¶
Schedule a task for execution.
-
inline explicit busy_pool(std::size_t n = std::thread::hardware_concurrency(), numa_strategy strategy = numa_strategy::fan)¶