11#include <condition_variable>
44 return static_cast<unsigned>(
workers.size());
53 const std::function<
void(std::size_t)>& task);
66 std::condition_variable_any
wake;
67 std::deque<std::function<void()>>
jobs;
Small fixed-size pool of background workers for batch work.
Definition thread_pool.h:30
void parallelFor(std::size_t count, const std::function< void(std::size_t)> &task)
Definition thread_pool.cpp:125
static unsigned defaultThreadCount()
Definition thread_pool.cpp:148
~ThreadPool()
Definition thread_pool.cpp:99
std::deque< std::function< void()> > jobs
Definition thread_pool.h:67
static constexpr unsigned MAX_THREADS
Definition thread_pool.h:33
unsigned getWorkerCount() const
Definition thread_pool.h:42
std::condition_variable_any wake
Definition thread_pool.h:66
void workerLoop(const std::stop_token &stop)
Definition thread_pool.cpp:109
ThreadPool(const ThreadPool &)=delete
std::mutex mutex
Definition thread_pool.h:65
std::vector< std::jthread > workers
Definition thread_pool.h:69
ThreadPool & operator=(const ThreadPool &)=delete