![]() |
Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
|
#include <thread-pool.hh>
Public Types | |
| using | work_t = boost::compat::move_only_function<void()> |
Public Member Functions | |
| ThreadPool (size_t maxThreads=0) | |
| void | enqueue (work_t t) |
| void | process () |
| void | shutdown () |
A simple thread pool that executes a queue of work items (lambdas).
| using nix::ThreadPool::work_t = boost::compat::move_only_function<void()> |
An individual work item.
Move-only, so that a work item can own what it operates on. std::move_only_function would do, but libc++ does not implement it yet.
| void nix::ThreadPool::enqueue | ( | 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.
| void nix::ThreadPool::shutdown | ( | ) |
Shut down all worker threads and wait until they've exited. Active work items are finished, but any pending work items are discarded.