boost::capy::thread_pool
A pool of threads for executing work concurrently.
Synopsis
Declared in <boost/capy/ex/thread_pool.hpp>
class thread_pool
: public execution_context
Description
Use this when you need to run coroutines on multiple threads without the overhead of creating and destroying threads for each task. Work items are distributed across the pool using a shared queue.
Example
thread_pool pool(4); // 4 worker threads
auto ex = pool.get_executor();
ex.post(some_coroutine);
// pool destructor waits for all work to complete
Base Classes
| Name | Description |
|---|---|
Base class for I/O object containers providing service management. |
Types
Name |
Description |
An executor that submits work to a thread_pool. |
|
Abstract base class for services owned by an execution context. |
Member Functions
Name |
Description |
|
Construct a thread pool. |
|
Destroy the thread pool. |
|
Assignment operators |
Return a pointer to the service of type T, or nullptr. |
|
Return an executor for this thread pool. |
|
Return the memory resource used for coroutine frame allocation. |
|
Return true if a service of type T exists. |
|
Construct and add a service. |
|
|
|
Request all worker threads to stop. |
|
Return a pointer to this context if it matches the requested type. |
|
Return a reference to the service of type T, creating it if needed. |
Non-Member Functions
Name |
Description |
Return the process‐wide system execution context. |
Created with MrDocs