A class that implements a thread pool for executing tasks concurrently.
More...
#include <ThreadPool.h>
A class that implements a thread pool for executing tasks concurrently.
The CThreadPool class manages a fixed number of worker threads that execute tasks from a task queue.
◆ EError
An enumeration of possible errors that can occur when executing the thread pool.
| Enumerator |
|---|
| ESuccess | The operation was successful.
|
| EAlreadyExecuted | The thread pool has already been executed.
|
◆ CThreadPool() [1/3]
| Devel::Threading::CThreadPool::CThreadPool |
( |
const size_t |
i_nWorkerCount | ) |
|
|
inlineexplicit |
Constructor that sets the worker count for the thread pool.
- Parameters
-
| i_nWorkerCount | The number of worker threads in the thread pool. |
◆ CThreadPool() [2/3]
| Devel::Threading::CThreadPool::CThreadPool |
( |
CThreadPool & |
i_oPool | ) |
|
|
delete |
Deleted copy constructor for CThreadPool. This copy constructor is explicitly deleted to prevent copying of CThreadPool objects.
- Parameters
-
◆ CThreadPool() [3/3]
| Devel::Threading::CThreadPool::CThreadPool |
( |
CThreadPool * |
i_pPool | ) |
|
|
delete |
Deleted constructor for CThreadPool that takes a pointer. This constructor is explicitly deleted to prevent creation of CThreadPool objects using a pointer to another CThreadPool object.
- Parameters
-
◆ addTask() [1/2]
| void Devel::Threading::CThreadPool::addTask |
( |
const ThreadPoolTaskFn & |
i_oTask | ) |
|
|
inline |
Adds a task to the task queue.
- Parameters
-
| i_oTask | The task to be added. |
◆ addTask() [2/2]
| void Devel::Threading::CThreadPool::addTask |
( |
ThreadPoolTaskFn && |
i_oTask | ) |
|
|
inline |
Adds a task to the task queue.
- Parameters
-
| i_oTask | The task to be added. |
◆ execute() [1/2]
Executes the thread pool with the current worker count.
- Returns
- The execution result.
◆ execute() [2/2]
| EError Devel::Threading::CThreadPool::execute |
( |
const size_t |
i_nWorkerCount | ) |
|
|
inline |
Executes the thread pool with a specified worker count.
- Parameters
-
| i_nWorkerCount | The number of worker threads to use in the thread pool. |
- Returns
- The execution result.
◆ isExecuted()
| bool Devel::Threading::CThreadPool::isExecuted |
( |
| ) |
const |
|
inline |
Checks if the thread pool has been executed.
- Returns
- True if the thread pool has been executed, false otherwise.
◆ setWorkerCount()
| void Devel::Threading::CThreadPool::setWorkerCount |
( |
const size_t |
i_nWorkerCount | ) |
|
|
inline |
Sets the worker count for the thread pool.
- Parameters
-
| i_nWorkerCount | The number of worker threads to use in the thread pool. |
◆ stop()
| void Devel::Threading::CThreadPool::stop |
( |
bool |
i_fClearTasks = true | ) |
|
Stops the execution of the thread pool.
- Parameters
-
| i_fClearTasks | Flag indicating whether to clear the task queue. |
◆ workerCount()
| size_t Devel::Threading::CThreadPool::workerCount |
( |
| ) |
const |
|
inline |
Returns the current worker count of the thread pool.
- Returns
- The worker count.
The documentation for this class was generated from the following files:
- /home/runner/work/devel-library/devel-library/Threading/ThreadPool/ThreadPool.h
- /home/runner/work/devel-library/devel-library/Threading/ThreadPool/ThreadPool.cpp