![]() |
PIP 5.6.1
Platform-Independent Primitives
|
Fixed-size pool of worker threads for fire-and-forget tasks. More...
#include <pithreadpoolexecutor.h>
Public Member Functions | |
| PIThreadPoolExecutor (int corePoolSize) | |
| Constructs executor with corePoolSize worker threads. | |
| virtual | ~PIThreadPoolExecutor () |
| Stops worker threads and destroys executor resources. | |
| void | execute (const std::function< void()> &runnable) |
| Submits runnable for asynchronous execution by a worker thread.This is a best-effort fire-and-forget call and does not report whether the task was accepted. \After shutdown requests new tasks are ignored. | |
| void | shutdownNow () |
| Requests immediate shutdown and stops worker threads without waiting for queued tasks to finish. | |
| void | shutdown () |
| Requests orderly shutdown: new tasks are rejected and workers stop after the current queue is drained. This method does not wait for worker termination. | |
| bool | isShutdown () const |
Returns true after shutdown() or shutdownNow() has been requested. | |
| bool | awaitTermination (PISystemTime timeout) |
Waits up to timeout for all worker threads to finish. false if the timeout expires first. | |
Fixed-size pool of worker threads for fire-and-forget tasks.
Thread pools address two different problems: they usually provide improved performance when executing large numbers of asynchronous tasks, due to reduced per-task invocation overhead, and they provide a means of bounding and managing the resources, including threads, consumed when executing a collection of tasks.