17#include <condition_variable>
55 void parallelFor(
int count,
const std::function<
void(
int begin,
int end)>& fn);
70 const std::function<void(
int,
int)>*
currentFn_ =
nullptr;
const std::function< void(int, int)> * currentFn_
Definition WorkerPool.hpp:70
int currentGeneration_
Definition WorkerPool.hpp:73
WorkerPool(int numWorkers)
Spin up numWorkers persistent threads.
Definition WorkerPool.cpp:9
WorkerPool(const WorkerPool &)=delete
std::vector< std::thread > workers_
Definition WorkerPool.hpp:60
WorkerPool & operator=(const WorkerPool &)=delete
int currentChunkSize_
Definition WorkerPool.hpp:72
WorkerPool & operator=(WorkerPool &&)=delete
std::condition_variable cvDone_
Definition WorkerPool.hpp:69
int currentTotal_
Definition WorkerPool.hpp:71
int numWorkers() const noexcept
Number of worker threads (excluding the calling thread).
Definition WorkerPool.hpp:42
std::atomic< int > outstanding_
Definition WorkerPool.hpp:74
void parallelFor(int count, const std::function< void(int begin, int end)> &fn)
Run fn in parallel over the index range [0, count).
Definition WorkerPool.cpp:31
std::mutex mtx_
Definition WorkerPool.hpp:67
std::condition_variable cvWork_
Definition WorkerPool.hpp:68
std::atomic< bool > stop_
Definition WorkerPool.hpp:75
WorkerPool(WorkerPool &&)=delete
~WorkerPool()
Definition WorkerPool.cpp:18
void workerLoop(int workerId)
Definition WorkerPool.cpp:89