|
ORIGINAL
|
Thread pool for managing and executing prioritized tasks. More...
#include <tasks.h>

Public Types | |
| enum class | priority : u_integer { IMMEDIATE = 0 , HIGH = 1 , NORMAL = 2 , LOW = 3 , DEFERRED = 4 } |
| Task priority levels for execution scheduling. More... | |
| enum class | stopMode { DISCARD_DEFERRED , KEEP_DEFERRED , RUN_DEFERRED } |
| Stop behavior for deferred tasks. More... | |
Public Member Functions | |
| taskDelegator (const taskDelegator &)=delete | |
| Disable copy constructor. | |
| taskDelegator & | operator= (const taskDelegator &)=delete |
| Disable copy assignment. | |
| taskDelegator (taskDelegator &&)=delete | |
| Disable move constructor. | |
| taskDelegator & | operator= (taskDelegator &&)=delete |
| Disable move assignment. | |
| taskDelegator (u_integer thread_cnt=8) | |
| Constructs a task delegator with a given number of threads. | |
| template<typename Callback , typename... Args> | |
| auto | submit (Callback &&c, Args &&... args) |
| Submits a task with normal priority. | |
| template<typename Callback , typename... Args> | |
| auto | submit (priority priority, Callback &&c, Args &&... args) |
| Submits a task with specified priority. | |
| template<typename Callback , typename... Args> | |
| auto | submit (time::duration timeout, Callback &&c, Args &&... args) |
| Submits a task with IMMEDIATE priority and a timeout. | |
| u_integer | waitingCnt () const noexcept |
| Returns the number of waiting (non-immediate, non-deferred) tasks. | |
| u_integer | immediateCnt () const noexcept |
| Returns the number of immediate tasks pending execution. | |
| void | runDeferred () |
| Activates one deferred task. | |
| void | runAllDeferred () |
| Activates all deferred tasks. | |
| u_integer | discardDeferred () |
| Discards one deferred task. | |
| void | discardAllDeferred () |
| Discards all deferred tasks. | |
| u_integer | deferredCnt () const noexcept |
| Returns number of deferred tasks. | |
| void | stop (stopMode mode=stopMode::KEEP_DEFERRED) |
| Stops the task delegator. | |
| u_integer | activeThreads () const noexcept |
| Gets the number of active threads. | |
| u_integer | idleThreads () const noexcept |
| Gets the number of idle threads. | |
| ~taskDelegator () | |
| Destructor. | |
| template<typename TYPE > | |
| original::async::future< TYPE > | submit (const priority priority, strongPtr< task< TYPE > > &t) |
Static Public Attributes | |
| static constexpr auto | IMMEDIATE = priority::IMMEDIATE |
| static constexpr auto | HIGH = priority::HIGH |
| static constexpr auto | NORMAL = priority::NORMAL |
| static constexpr auto | LOW = priority::LOW |
| static constexpr auto | DEFERRED = priority::DEFERRED |
| static constexpr auto | DISCARD_DEFERRED = stopMode::DISCARD_DEFERRED |
| static constexpr auto | KEEP_DEFERRED = stopMode::KEEP_DEFERRED |
| static constexpr auto | RUN_DEFERRED = stopMode::RUN_DEFERRED |
Thread pool for managing and executing prioritized tasks.
Provides a managed thread pool that can execute tasks with different priority levels. Supports immediate, high, normal, low, and deferred tasks. Deferred tasks can be manually activated or discarded on shutdown.
|
inlineexplicit |
Constructs a task delegator with a given number of threads.
| thread_cnt | Number of threads (default: 8) |
|
inline |
Destructor.
Calls stop(RUN_DEFERRED) and joins all threads
|
inlinenoexcept |
Gets the number of active threads.
|
inline |
Discards one deferred task.
|
inlinenoexcept |
Gets the number of idle threads.
|
inline |
Stops the task delegator.
| mode | Stop mode (default: KEEP_DEFERRED) |
Submits a task with normal priority.
| Callback | Type of the callable |
| Args | Types of the arguments |
| c | Callable to execute |
| args | Arguments to forward to the callable |
Submits a task with specified priority.
| Callback | Type of the callable |
| Args | Types of the arguments |
| priority | Task priority level |
| c | Callable to execute |
| args | Arguments to forward to the callable |
| sysError | if delegator is stopped or no idle thread is available for IMMEDIATE submission |
| auto original::taskDelegator::submit | ( | time::duration | timeout, |
| Callback && | c, | ||
| Args &&... | args | ||
| ) |
Submits a task with IMMEDIATE priority and a timeout.
| Callback | Type of the callable |
| Args | Types of the arguments |
| timeout | Maximum duration to wait for an idle thread |
| c | Callable to execute |
| args | Arguments to forward to the callable |
| sysError | if delegator is stopped |
| sysError | if no idle thread becomes available within the timeout |