|
C++ Concurrency Sandbox
|
Manages a collection of threads that execute tasks from a shared queue. More...
Public Member Functions | |
| ThreadPool (size_t num_threads) | |
| Construct a new Thread Pool and spawns worker threads. | |
| void | enqueue (Task t) |
| Submits a task to the queue for execution. | |
| ~ThreadPool () | |
| Destructor that ensures all threads finish current work before exiting. | |
| ThreadPool (size_t num_threads) | |
| Constructs the pool and starts the worker threads. | |
| void | enqueue (Task t) |
| Enqueues a Task (functor/lambda) into the work queue. | |
| ~ThreadPool () | |
| Joins all threads for a clean shutdown. | |
Manages a collection of threads that execute tasks from a shared queue.
A pool of persistent workers that execute generic Task objects.
Manages a set of persistent threads to execute fire-and-forget tasks.
Definition at line 36 of file BasicThreadPool.cpp.
|
inline |
Construct a new Thread Pool and spawns worker threads.
| num_threads | The number of worker threads to maintain in the pool. |
Definition at line 83 of file BasicThreadPool.cpp.
|
inline |
Destructor that ensures all threads finish current work before exiting.
Definition at line 107 of file BasicThreadPool.cpp.
|
inline |
Constructs the pool and starts the worker threads.
| num_threads | Number of threads to spawn. |
Definition at line 104 of file MessagePassing.cpp.
|
inline |
Joins all threads for a clean shutdown.
Definition at line 125 of file MessagePassing.cpp.
|
inline |
Submits a task to the queue for execution.
| t | The task to execute (must match void() signature). |
Definition at line 95 of file BasicThreadPool.cpp.
Referenced by main().
|
inline |
Enqueues a Task (functor/lambda) into the work queue.
| t | The task to be executed by a worker. |
Definition at line 114 of file MessagePassing.cpp.