#include <thread-pool.hh>
Public Types | |
typedef std::function< void()> | work_t |
Public Member Functions | |
ThreadPool (size_t maxThreads=0) | |
void | enqueue (const work_t &t) |
void | process () |
A simple thread pool that executes a queue of work items (lambdas).
typedef std::function<void()> nix::ThreadPool::work_t |
An individual work item.
void nix::ThreadPool::enqueue | ( | const work_t & | t | ) |
Enqueue a function to be executed by the thread pool.
void nix::ThreadPool::process | ( | ) |
Execute work items until the queue is empty.
Queue processing stops prematurely if any work item throws an exception. This exception is propagated to the calling thread. If multiple work items throw an exception concurrently, only one item is propagated; the others are printed on stderr and otherwise ignored.