ORIGINAL
Loading...
Searching...
No Matches
original::taskDelegator Class Reference

Thread pool for managing and executing tasks with priority. More...

#include <tasks.h>

Collaboration diagram for original::taskDelegator:
Collaboration graph

Public Types

enum class  priority : u_integer {
  IMMEDIATE = 0 , HIGH = 1 , NORMAL = 2 , LOW = 3 ,
  DEFERRED = 4
}
 Task priority levels for execution scheduling. More...
 

Public Member Functions

 taskDelegator (u_integer thread_cnt=8)
 Constructs a task delegator with specified thread count.
 
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 TYPE >
async::future< TYPE > submit (strongPtr< task< TYPE > > &t)
 Submits a pre-created task with normal priority.
 
template<typename TYPE >
async::future< TYPE > submit (priority priority, strongPtr< task< TYPE > > &t)
 Submits a pre-created task with specified priority.
 
void runDeferred ()
 Moves one deferred task to the waiting queue.
 
void runAllDeferred ()
 Moves all deferred tasks to the waiting queue.
 
void stop ()
 Stops the task delegator and waits for completion.
 
u_integer activeThreads () const noexcept
 Gets the number of active threads.
 
u_integer idleThreads () const noexcept
 Gets the number of idle threads.
 
 ~taskDelegator ()
 Destructor - automatically stops if not already stopped.
 
template<typename TYPE >
original::async::future< TYPE > submit (strongPtr< task< TYPE > > &t)
 
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
 

Detailed Description

Thread pool for managing and executing tasks with priority.

Provides a managed thread pool with task prioritization, deferred execution, and resource monitoring

Member Enumeration Documentation

◆ priority

Task priority levels for execution scheduling.

Enumerator
IMMEDIATE 

Execute immediately if threads available.

HIGH 

High priority task.

NORMAL 

Normal priority task (default)

LOW 

Low priority task.

DEFERRED 

Deferred execution (manual activation)

Constructor & Destructor Documentation

◆ taskDelegator()

original::taskDelegator::taskDelegator ( u_integer thread_cnt = 8)
inlineexplicit

Constructs a task delegator with specified thread count.

Parameters
thread_cntNumber of worker threads (default: 8)

Member Function Documentation

◆ activeThreads()

original::u_integer original::taskDelegator::activeThreads ( ) const
inlinenoexcept

Gets the number of active threads.

Returns
Count of currently active threads

◆ idleThreads()

original::u_integer original::taskDelegator::idleThreads ( ) const
inlinenoexcept

Gets the number of idle threads.

Returns
Count of currently idle threads

◆ submit() [1/4]

template<typename Callback , typename ... Args>
auto original::taskDelegator::submit ( Callback && c,
Args &&... args )

Submits a task with normal priority.

Template Parameters
CallbackType of the callable
ArgsTypes of the arguments
Parameters
cCallable to execute
argsArguments to forward to the callable
Returns
Future for the task result

◆ submit() [2/4]

template<typename Callback , typename ... Args>
auto original::taskDelegator::submit ( priority priority,
Callback && c,
Args &&... args )

Submits a task with specified priority.

Template Parameters
CallbackType of the callable
ArgsTypes of the arguments
Parameters
priorityTask priority level
cCallable to execute
argsArguments to forward to the callable
Returns
Future for the task result

◆ submit() [3/4]

template<typename TYPE >
async::future< TYPE > original::taskDelegator::submit ( priority priority,
strongPtr< task< TYPE > > & t )

Submits a pre-created task with specified priority.

Template Parameters
TYPETask result type
Parameters
priorityTask priority level
tShared pointer to the task
Returns
Future for the task result

◆ submit() [4/4]

template<typename TYPE >
async::future< TYPE > original::taskDelegator::submit ( strongPtr< task< TYPE > > & t)

Submits a pre-created task with normal priority.

Template Parameters
TYPETask result type
Parameters
tShared pointer to the task
Returns
Future for the task result

The documentation for this class was generated from the following file: