CGraph
Protected Member Functions | Private Attributes | Friends | List of all members
GDynamicEngine Class Reference

CGraph的核心引擎,提供DAG类型分析、拓扑分析、动态图运行、全并发执行、全串行执行等能力 More...

#include <GDynamicEngine.h>

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

Protected Member Functions

 GDynamicEngine ()=default
 
CStatus setup (const GSortedGElementPtrSet &elements) override
 
CStatus run () override
 
CVoid mark (const GSortedGElementPtrSet &elements)
 
CVoid analysisDagType (const GSortedGElementPtrSet &elements)
 
CVoid commonRunAll ()
 
CVoid process (GElementPtr element, CBool affinity)
 
CVoid afterElementRun (GElementPtr element)
 
CVoid fatWait ()
 
CVoid parallelRunAll ()
 
CVoid serialRunAll ()
 
- Protected Member Functions inherited from GEngine
 GEngine ()=default
 
CVoid link (const GSortedGElementPtrSet &elements)
 

Private Attributes

GElementPtrArr total_element_arr_
 
GElementPtrArr front_element_arr_
 
CSize total_end_size_ = 0
 
CSize finished_end_size_ = 0
 
CStatus cur_status_
 
internal::GEngineDagType dag_type_ = { internal::GEngineDagType::COMMON }
 
std::mutex lock_
 
std::condition_variable cv_
 
std::mutex status_lock_
 

Friends

class CAllocator
 

Additional Inherited Members

- Public Member Functions inherited from CObject
 CObject ()=default
 
virtual CStatus init ()
 
virtual CStatus destroy ()
 
virtual ~CObject ()=default
 
- Static Protected Member Functions inherited from GEngine
static GElementPtrArr getTopo (const GSortedGElementPtrSet &elements)
 
static CBool isDag (const GSortedGElementPtrSet &elements)
 
- Protected Attributes inherited from GEngine
UThreadPoolPtr thread_pool_ { nullptr }
 
CSize linked_size_ = 0
 

Detailed Description

CGraph的核心引擎,提供DAG类型分析、拓扑分析、动态图运行、全并发执行、全串行执行等能力

Constructor & Destructor Documentation

◆ GDynamicEngine()

GDynamicEngine::GDynamicEngine ( )
explicitprotecteddefault

Member Function Documentation

◆ afterElementRun()

CVoid GDynamicEngine::afterElementRun ( GElementPtr  element)
protected

element 运行完成处理

Parameters
element
Returns

满足一下条件之一,则通知wait函数停止等待 1,无后缀节点全部执行完毕(在运行正常的情况下,只有无后缀节点执行完成的时候,才可能整体运行结束) 2,有节点执行状态异常

Here is the call graph for this function:

◆ analysisDagType()

CVoid GDynamicEngine::analysisDagType ( const GSortedGElementPtrSet elements)
protected

分析当前的信息,主要用于区分dag的类型

Returns

如果所有的信息中,只有一个是非linkable。则说明只有最后的那个是的,且只有一个开头 故,这里将其认定为一条 lineal 的情况 ps: 只有一个或者没有 element的情况,也会被算到 ALL_SERIAL 中去

◆ commonRunAll()

CVoid GDynamicEngine::commonRunAll ( )
protected

动态图运行

Parameters
  1. 执行没有任何依赖的element
  2. 在element执行完成之后,进行裂变,直到所有的element执行完成
  3. 等待异步执行结束
Here is the call graph for this function:

◆ fatWait()

CVoid GDynamicEngine::fatWait ( )
protected

动态图运行等待

Parameters

遇到以下条件之一,结束执行: 1,执行结束 2,状态异常

◆ mark()

CVoid GDynamicEngine::mark ( const GSortedGElementPtrSet elements)
protected

记录当前 elements 数据信息

Parameters
elements
Returns

◆ parallelRunAll()

CVoid GDynamicEngine::parallelRunAll ( )
protected

并发的执行所有的element

Returns

主要适用于dag是纯并发逻辑的情况 直接并发的执行所有的流程,从而减少调度损耗 实测效果,在32路纯并行的情况下,整体耗时从 21.5s降低到 12.5s 非纯并行逻辑,不走此函数

Here is the call graph for this function:

◆ process()

CVoid GDynamicEngine::process ( GElementPtr  element,
CBool  affinity 
)
protected

element 运行element

Parameters
element
affinity是否本地执行
Returns
Here is the call graph for this function:

◆ run()

CStatus GDynamicEngine::run ( )
overrideprotectedvirtual

流程处理函数

Implements CObject.

Here is the call graph for this function:

◆ serialRunAll()

CVoid GDynamicEngine::serialRunAll ( )
protected

串行的执行所有element

Returns

如果分析出来 dag是一个链式的,则直接依次执行element 直到所有element都执行完成,或者有出现错误的返回值

Here is the call graph for this function:

◆ setup()

CGRAPH_NAMESPACE_BEGIN CStatus GDynamicEngine::setup ( const GSortedGElementPtrSet elements)
overrideprotectedvirtual

将所有注册进入 pipeline的内容,进行分析和解构

Parameters
elements
Returns
  1. 判断是否是 dag 结构
  2. 标记数据,比如有多少个结束element等
  3. 标记哪些数据,是linkable 的
  4. 分析当前dag类型信息

Implements GEngine.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ CAllocator

friend class CAllocator
friend

Member Data Documentation

◆ cur_status_

CStatus GDynamicEngine::cur_status_
private

◆ cv_

std::condition_variable GDynamicEngine::cv_
private

◆ dag_type_

internal::GEngineDagType GDynamicEngine::dag_type_ = { internal::GEngineDagType::COMMON }
private

◆ finished_end_size_

CSize GDynamicEngine::finished_end_size_ = 0
private

◆ front_element_arr_

GElementPtrArr GDynamicEngine::front_element_arr_
private

◆ lock_

std::mutex GDynamicEngine::lock_
private

◆ status_lock_

std::mutex GDynamicEngine::status_lock_
private

◆ total_element_arr_

GElementPtrArr GDynamicEngine::total_element_arr_
private

◆ total_end_size_

CSize GDynamicEngine::total_end_size_ = 0
private

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