class
ThreadPoolA thread pool wrapper for managing concurrent tasks.
The ThreadPool class wraps around BS::thread_pool and provides a simplified interface for submitting tasks, pushing loops of tasks, and waiting for all tasks to complete.
Public types
-
template<class T>using MultiFuture = BS::multi_future<T>
- Alias for a multi_future type returned by task submissions.
Constructors, destructors, conversion operators
- ThreadPool(size_t threadCount)
- Constructs a ThreadPool with a specified number of threads.
Public functions
- auto reset(size_t threadCount) -> ThreadPool&
- Resets the thread pool with a new thread count.
-
template<class ... Args>auto submit(Args... args) -> auto
- Submits a task to the thread pool.
-
template<class ... Args>void pushLoop(Args... args)
- Pushes a loop of tasks to the thread pool.
- void waitForTasks()
- Waits for all tasks in the thread pool to complete.
- auto getThreadCount() const -> auto
- Retrieves the current number of threads in the pool.
Typedef documentation
template<class T>
using Rodin:: Threads:: ThreadPool:: MultiFuture = BS::multi_future<T>
Alias for a multi_future type returned by task submissions.
Template parameters | |
---|---|
T | The type of the value produced by the tasks. |
Function documentation
Rodin:: Threads:: ThreadPool:: ThreadPool(size_t threadCount)
Constructs a ThreadPool with a specified number of threads.
Parameters | |
---|---|
threadCount | The number of threads to create in the pool. |
ThreadPool& Rodin:: Threads:: ThreadPool:: reset(size_t threadCount)
Resets the thread pool with a new thread count.
Parameters | |
---|---|
threadCount | The new number of threads for the pool. |
Returns | A reference to this ThreadPool instance. |
This function reinitializes the thread pool to use the specified number of threads.
template<class ... Args>
auto Rodin:: Threads:: ThreadPool:: submit(Args... args)
Submits a task to the thread pool.
Template parameters | |
---|---|
Args | The types of the arguments to be forwarded. |
Parameters | |
args | The arguments for the task to be submitted. |
Returns | A future or multi_future representing the submitted task. |
Forwards the provided arguments to BS::thread_pool::submit.
template<class ... Args>
void Rodin:: Threads:: ThreadPool:: pushLoop(Args... args)
Pushes a loop of tasks to the thread pool.
Template parameters | |
---|---|
Args | The types of the arguments to be forwarded. |
Parameters | |
args | The arguments for the loop of tasks to be pushed. |
Returns | A future or multi_future representing the pushed tasks. |
Forwards the provided arguments to BS::thread_pool::push_loop.
auto Rodin:: Threads:: ThreadPool:: getThreadCount() const
Retrieves the current number of threads in the pool.
Returns | The number of threads currently used by the thread pool. |
---|