8#include <condition_variable>
27 std::queue<std::function<void()>>
tasks;
32 explicit ThreadPool(
size_t threads = std::thread::hardware_concurrency());
45 void enqueue(std::function<
void()> task);
A thread pool implementation that manages a pool of worker threads to execute tasks concurrently.
Definition ThreadPool.h:24
bool stop
Definition ThreadPool.h:30
ThreadPool(const ThreadPool &other)=delete
~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:29
size_t getThreadCount() const
Definition ThreadPool.cpp:65
std::vector< std::thread > workers
Definition ThreadPool.h:26
void cleanup()
Definition ThreadPool.cpp:55
ThreadPool(ThreadPool &&other) noexcept=delete
ThreadPool & operator=(const ThreadPool &other)=delete
std::mutex queue_mutex
Definition ThreadPool.h:28
ThreadPool & operator=(ThreadPool &&other) noexcept=delete
std::queue< std::function< void()> > tasks
Definition ThreadPool.h:27