9#include <condition_variable>
28 std::queue<std::function<void()>>
tasks;
34 explicit ThreadPool(
size_t threads = std::thread::hardware_concurrency());
47 void enqueue(std::function<
void()> task);
A thread pool implementation that manages a pool of worker threads to execute tasks concurrently.
Definition ThreadPool.h:25
bool stop
Definition ThreadPool.h:31
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:30
bool isActive() const
Definition ThreadPool.cpp:71
size_t getThreadCount() const
Definition ThreadPool.cpp:67
std::vector< std::thread > workers
Definition ThreadPool.h:27
void cleanup()
Definition ThreadPool.cpp:56
ThreadPool(ThreadPool &&other) noexcept=delete
ThreadPool & operator=(const ThreadPool &other)=delete
std::mutex queue_mutex
Definition ThreadPool.h:29
ThreadPool & operator=(ThreadPool &&other) noexcept=delete
std::queue< std::function< void()> > tasks
Definition ThreadPool.h:28
std::atomic< bool > active
Definition ThreadPool.h:32