25 #ifndef _ALEXANDRIAKERNEL_THREADPOOL_H 26 #define _ALEXANDRIAKERNEL_THREADPOOL_H 73 using Task = std::function<void(void)>;
83 explicit ThreadPool(
unsigned int thread_count=std::thread::hardware_concurrency(),
unsigned int empty_queue_wait_time=50);
std::deque< Task > m_queue
void submit(Task task)
Submit a task to be executed.
std::vector< std::atomic< bool > > m_worker_sleeping_flags
Basic thread pool implementation.
std::vector< std::atomic< bool > > m_worker_run_flags
ThreadPool(unsigned int thread_count=std::thread::hardware_concurrency(), unsigned int empty_queue_wait_time=50)
Constructs a new ThreadPool.
bool checkForException(bool rethrow=false)
Checks if any task has thrown an exception and optionally rethrows it.
std::vector< std::atomic< bool > > m_worker_done_flags
unsigned int m_empty_queue_wait_time
std::exception_ptr m_exception_ptr
std::function< void(void)> Task
The type of tasks the pool can execute.