25 #ifndef _ALEXANDRIAKERNEL_THREADPOOL_H
26 #define _ALEXANDRIAKERNEL_THREADPOOL_H
std::deque< Task > m_queue
void submit(Task task)
Submit a task to be executed.
std::vector< std::atomic< bool > > m_worker_sleeping_flags
T hardware_concurrency(T...args)
size_t queued() const
Return the number of queued tasks.
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::thread > m_workers
size_t activeThreads() const
Return the number of active workers (either running or sleeping)
std::vector< std::atomic< bool > > m_worker_done_flags
unsigned int m_empty_queue_wait_time
size_t running() const
Return the number of running tasks.
std::exception_ptr m_exception_ptr