25#ifndef _ALEXANDRIAKERNEL_THREADPOOL_H
26#define _ALEXANDRIAKERNEL_THREADPOOL_H
83 unsigned int empty_queue_wait_time = 50);
94 void block(
bool throw_on_exception =
true);
Basic thread pool implementation.
void submit(Task task)
Submit a task to be executed.
std::deque< Task > m_queue
size_t running() const
Return the number of running tasks.
void block(bool throw_on_exception=true)
std::vector< std::atomic< bool > > m_worker_sleeping_flags
size_t queued() const
Return the number of queued tasks.
unsigned int m_empty_queue_wait_time
std::vector< std::thread > m_workers
std::vector< std::atomic< bool > > m_worker_run_flags
std::vector< std::atomic< bool > > m_worker_done_flags
bool checkForException(bool rethrow=false)
Checks if any task has thrown an exception and optionally rethrows it.
std::exception_ptr m_exception_ptr
size_t activeThreads() const
Return the number of active workers (either running or sleeping)
T hardware_concurrency(T... args)