CGraph
Public Member Functions | Private Attributes | Friends | List of all members
UTaskGroup Class Reference

注意,并非基于UTask,实际维护的是CGRAPH_DEFAULT_FUNCTION类型的函数数组(std::vector) 支持addTask将更多的函数加入task_arr_数组,支持指定任务组最大执行耗时ttl 以及对task_arr_数组内的全部函数执行完成(即这个UTaskGroup执行完成)指定后处理接口setOnFinished More...

#include <UTaskGroup.h>

Inheritance diagram for UTaskGroup:
Inheritance graph
[legend]
Collaboration diagram for UTaskGroup:
Collaboration graph
[legend]

Public Member Functions

 UTaskGroup ()=default
 
 UTaskGroup (CGRAPH_DEFAULT_CONST_FUNCTION_REF task, CMSec ttl=CGRAPH_MAX_BLOCK_TTL, CGRAPH_CALLBACK_CONST_FUNCTION_REF onFinished=nullptr) noexcept
 
UTaskGroupaddTask (CGRAPH_DEFAULT_CONST_FUNCTION_REF task)
 
UTaskGroupsetTtl (CMSec ttl)
 
UTaskGroupsetOnFinished (CGRAPH_CALLBACK_CONST_FUNCTION_REF onFinished)
 
CMSec getTtl () const
 
CVoid clear ()
 
CSize getSize () const
 
- Public Member Functions inherited from CObject
 CObject ()=default
 
virtual CStatus init ()
 
virtual CStatus destroy ()
 
virtual ~CObject ()=default
 

Private Attributes

std::vector< CGRAPH_DEFAULT_FUNCTIONtask_arr_
 
CMSec ttl_ = CGRAPH_MAX_BLOCK_TTL
 
CGRAPH_CALLBACK_FUNCTION on_finished_ = nullptr
 

Friends

class UThreadPool
 

Additional Inherited Members

- Protected Member Functions inherited from UThreadObject
CStatus run () override
 
- Protected Member Functions inherited from UtilsObject
CStatus run () override
 

Detailed Description

注意,并非基于UTask,实际维护的是CGRAPH_DEFAULT_FUNCTION类型的函数数组(std::vector) 支持addTask将更多的函数加入task_arr_数组,支持指定任务组最大执行耗时ttl 以及对task_arr_数组内的全部函数执行完成(即这个UTaskGroup执行完成)指定后处理接口setOnFinished

Constructor & Destructor Documentation

◆ UTaskGroup() [1/2]

UTaskGroup::UTaskGroup ( )
explicitdefault

◆ UTaskGroup() [2/2]

UTaskGroup::UTaskGroup ( CGRAPH_DEFAULT_CONST_FUNCTION_REF  task,
CMSec  ttl = CGRAPH_MAX_BLOCK_TTL,
CGRAPH_CALLBACK_CONST_FUNCTION_REF  onFinished = nullptr 
)
inlineexplicitnoexcept

直接通过函数来申明taskGroup

Parameters
task
ttl
onFinished
Here is the call graph for this function:

Member Function Documentation

◆ addTask()

UTaskGroup* UTaskGroup::addTask ( CGRAPH_DEFAULT_CONST_FUNCTION_REF  task)
inline

添加一个任务

Parameters
task

◆ clear()

CVoid UTaskGroup::clear ( )
inline

清空任务组

◆ getSize()

CSize UTaskGroup::getSize ( ) const
inline

获取任务组大小

Returns

◆ getTtl()

CMSec UTaskGroup::getTtl ( ) const
inline

获取最大超时时间信息

Returns

◆ setOnFinished()

UTaskGroup* UTaskGroup::setOnFinished ( CGRAPH_CALLBACK_CONST_FUNCTION_REF  onFinished)
inline

设置执行完成后的回调函数

Parameters
onFinished
Returns

◆ setTtl()

UTaskGroup* UTaskGroup::setTtl ( CMSec  ttl)
inline

设置任务最大超时时间

Parameters
ttl

Friends And Related Function Documentation

◆ UThreadPool

friend class UThreadPool
friend

Member Data Documentation

◆ on_finished_

CGRAPH_CALLBACK_FUNCTION UTaskGroup::on_finished_ = nullptr
private

◆ task_arr_

std::vector<CGRAPH_DEFAULT_FUNCTION> UTaskGroup::task_arr_
private

◆ ttl_

CMSec UTaskGroup::ttl_ = CGRAPH_MAX_BLOCK_TTL
private

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