7#include <condition_variable>
26 std::queue<std::function<void()>>
tasks;
31 ThreadPool(
size_t threads = std::thread::hardware_concurrency());
39 void enqueue(std::function<
void()> task);
A thread pool implementation that manages a pool of worker threads to execute tasks concurrently.
Definition ThreadPool.h:23
bool stop
Definition ThreadPool.h:29
~ThreadPool()
Definition ThreadPool.cpp:32
void enqueue(std::function< void()> task)
Enqueue a new task to be executed by the thread pool.
Definition ThreadPool.cpp:47
std::condition_variable condition
Definition ThreadPool.h:28
size_t getThreadCount() const
Definition ThreadPool.cpp:65
std::vector< std::thread > workers
Definition ThreadPool.h:25
void cleanup()
Definition ThreadPool.cpp:55
std::mutex queue_mutex
Definition ThreadPool.h:27
std::queue< std::function< void()> > tasks
Definition ThreadPool.h:26