4#include <condition_variable>
26 ThreadPool(
size_t thread_count = std::thread::hardware_concurrency());
64 void schedule(std::function<
void()> task)
override;
86 std::queue<std::function<void()>> _tasks;
87 std::condition_variable _condition;
88 std::vector<std::thread> _threads;
89 std::atomic<size_t> _active_tasks;
90 std::mutex _queue_mutex;
91 std::atomic<bool> _stop;
Definition: scheduler.hpp:5
Definition: threadpool.hpp:13
ThreadPool(size_t thread_count=std::thread::hardware_concurrency())
Construct a new ThreadPool object.
~ThreadPool()
Destroy the ThreadPool object.
void schedule(std::function< void()> task) override
Enqueues a new task to be executed by the thread pool.
ThreadPool(const ThreadPool &)=delete
void shutdown() override
Shuts down the thread pool and stops all worker threads.
ThreadPool(ThreadPool &&)=delete
ThreadPool & operator=(ThreadPool &&)=delete
void wait() override
Waits for all currently enqueued tasks to be completed.
ThreadPool & operator=(const ThreadPool &)=delete