ThreadSchedule 1.0.0
Modern C++ thread management library
|
Simple thread pool for general-purpose use. More...
#include <thread_pool.hpp>
Classes | |
struct | Statistics |
Public Types | |
using | Task = std::function<void()> |
Public Member Functions | |
ThreadPool (size_t num_threads=std::thread::hardware_concurrency()) | |
ThreadPool (ThreadPool const &)=delete | |
auto | operator= (ThreadPool const &) -> ThreadPool &=delete |
template<typename F, typename... Args> | |
auto | submit (F &&f, Args &&... args) -> std::future< std::invoke_result_t< F, Args... > > |
Submit a task to the thread pool. | |
template<typename Iterator> | |
auto | submit_range (Iterator begin, Iterator end) -> std::vector< std::future< void > > |
Submit multiple tasks. | |
template<typename Iterator, typename F> | |
void | parallel_for_each (Iterator begin, Iterator end, F &&func) |
Apply a function to a range of values in parallel. | |
auto | size () const noexcept -> size_t |
auto | pending_tasks () const -> size_t |
auto | configure_threads (std::string const &name_prefix, SchedulingPolicy policy=SchedulingPolicy::OTHER, ThreadPriority priority=ThreadPriority::normal()) -> bool |
Configure thread properties. | |
auto | set_affinity (ThreadAffinity const &affinity) -> bool |
auto | distribute_across_cpus () -> bool |
void | wait_for_tasks () |
void | shutdown () |
auto | get_statistics () const -> Statistics |
Simple thread pool for general-purpose use.
This is a straightforward thread pool implementation suitable for:
For high-throughput scenarios (> 1k tasks), consider FastThreadPool or HighPerformancePool.
Definition at line 887 of file thread_pool.hpp.
using threadschedule::ThreadPool::Task = std::function<void()> |
Definition at line 890 of file thread_pool.hpp.
|
inlineexplicit |
Definition at line 900 of file thread_pool.hpp.
|
inline |
Definition at line 915 of file thread_pool.hpp.
|
inline |
Configure thread properties.
Definition at line 1000 of file thread_pool.hpp.
|
inline |
Definition at line 1038 of file thread_pool.hpp.
|
inline |
Definition at line 1086 of file thread_pool.hpp.
|
inline |
Apply a function to a range of values in parallel.
Definition at line 969 of file thread_pool.hpp.
References submit().
|
inline |
Definition at line 991 of file thread_pool.hpp.
|
inline |
Definition at line 1023 of file thread_pool.hpp.
|
inline |
Definition at line 1064 of file thread_pool.hpp.
|
inlinenoexcept |
Definition at line 986 of file thread_pool.hpp.
|
inline |
Submit a task to the thread pool.
Definition at line 924 of file thread_pool.hpp.
Referenced by parallel_for_each(), and submit_range().
|
inline |
|
inline |
Definition at line 1058 of file thread_pool.hpp.