5#ifndef HOSHI_LANG_CODEGEN_TASK_DISPATCHER_HPP
6#define HOSHI_LANG_CODEGEN_TASK_DISPATCHER_HPP
9#include <condition_variable>
31 void dispatch(std::function<
void()> task);
51 std::atomic<bool>
stop{
false};
std::condition_variable queueCondition
void dispatch(std::function< void()> task)
Dispatch a task to the thread pool.
CodegenTaskDispatcher(const CodegenTaskDispatcher &)=delete
std::atomic< size_t > activeTasks
std::queue< std::function< void()> > taskQueue
void wait()
Wait for all dispatched tasks to complete.
CodegenTaskDispatcher & operator=(const CodegenTaskDispatcher &)=delete
std::vector< std::thread > workers
std::condition_variable waitCondition