|
asynchrony 2.3.1
Add asynchrony to your C++ applications using standard C++20
|
Public Member Functions | |
| simple_pool (simple_pool &&)=delete | |
| Move constructor (deleted - pools are not movable). | |
| simple_pool & | operator= (simple_pool &&)=delete |
| Move assignment operator (deleted - pools are not movable). | |
| simple_pool (simple_pool &)=delete | |
| Copy constructor (deleted - pools are not copyable). | |
| simple_pool & | operator= (simple_pool &)=delete |
| Copy assignment operator (deleted - pools are not copyable). | |
| ~simple_pool () | |
| Destructor - gracefully shuts down all worker threads. | |
| simple_pool (std::function< void(T &&)> c) | |
| Constructs a thread pool with N worker threads. | |
| void | queue (T &&item) |
| Queue a work item for processing. | |
Static Public Attributes | |
| static constexpr std::chrono::milliseconds | DEFAULT_WAIT_FOR_NEXT_ITEM_MS {1500} |
| Default wait interval for threads waiting on the semaphore. | |
Definition at line 91 of file simple_pool.hpp.
|
inline |
Destructor - gracefully shuts down all worker threads.
Performs the following cleanup steps:
Definition at line 120 of file simple_pool.hpp.
|
inline |
Constructs a thread pool with N worker threads.
Creates a pool of worker threads that process items from a shared queue. Each thread runs a loop that waits for items and invokes the callback.
| c | The worker callback function with signature void(T&&) Called for each item dequeued from the pool |
Definition at line 152 of file simple_pool.hpp.
|
inline |
Queue a work item for processing.
Adds an item to the shared queue and signals a waiting thread to process it. This method is thread-safe and can be called from multiple threads concurrently.
| item | The work item to queue (must be move-constructible) Ownership is transferred to the pool |
Definition at line 202 of file simple_pool.hpp.
|
staticconstexpr |
Default wait interval for threads waiting on the semaphore.
Definition at line 94 of file simple_pool.hpp.