Manages a pool of worker threads that consume tasks from a ThreadSafeQueue. Utilizes C++20 std::jthread for automatic joining.
More...
#include <src/core/ThreadPool.h>
|
| | ThreadPool () |
| | Constructs the thread pool. Defaults to (Hardware Threads - 1) to leave the main thread free.
|
| |
| | ~ThreadPool () |
| | Destructor. Stops all threads and joins them.
|
| |
| void | submit (std::function< void()> objJob) |
| | Submits a void() function/lambda to the pool.
|
| |
|
| void | worker_loop (std::stop_token st) |
| | The main loop for worker threads.
|
| |
Manages a pool of worker threads that consume tasks from a ThreadSafeQueue. Utilizes C++20 std::jthread for automatic joining.
◆ ThreadPool()
| Core::ThreadPool::ThreadPool |
( |
| ) |
|
|
inline |
Constructs the thread pool. Defaults to (Hardware Threads - 1) to leave the main thread free.
◆ ~ThreadPool()
| Core::ThreadPool::~ThreadPool |
( |
| ) |
|
|
inline |
Destructor. Stops all threads and joins them.
◆ submit()
| void Core::ThreadPool::submit |
( |
std::function< void()> |
objJob | ) |
|
|
inline |
Submits a void() function/lambda to the pool.
◆ worker_loop()
| void Core::ThreadPool::worker_loop |
( |
std::stop_token |
st | ) |
|
|
inlineprivate |
The main loop for worker threads.
- Parameters
-
| st | C++20 Stop Token to check for shutdown requests. |
◆ m_bDone
| std::atomic<bool> Core::ThreadPool::m_bDone |
|
private |
◆ m_objJThreads
| std::vector<std::jthread> Core::ThreadPool::m_objJThreads |
|
private |
◆ m_ObjQueue
The documentation for this class was generated from the following file: