CGraph
Protected Member Functions | Private Attributes | Friends | List of all members
GSome< TriggerNum > Class Template Reference

对于插入的所有GElement,不管实际能不能并行,GSome都会把这些GElement提交到异步任务里面全并发执行(详见run) TriggerNum个GElement执行完成后就退出不再执行剩余的,剩余的置为TIMEOUT(在GElement的fatProcessor里面会不执行直接结束) More...

#include <GSome.h>

Inheritance diagram for GSome< TriggerNum >:
Inheritance graph
[legend]
Collaboration diagram for GSome< TriggerNum >:
Collaboration graph
[legend]

Protected Member Functions

 GSome ()
 
CStatus addElement (GElementPtr element) final
 
CStatus run () final
 
CBool isSerializable () const final
 
CVoid dump (std::ostream &oss) final
 
CBool isHold () final
 
CStatus checkSuitable () final
 
- Protected Member Functions inherited from GElement
 GElement ()=default
 
 ~GElement () override
 
virtual CStatus prepareRun ()
 
virtual CStatus checkRunResult ()
 
virtual CBool isMatch ()
 
CStatus crashed (const CException &ex)
 
template<typename T , c_enable_if_t< std::is_base_of< GElementParam, T >::value, int > = 0>
T * getEParam (const std::string &key)
 
CIndex getThreadIndex ()
 
CBool isTimeout () const
 
CIndex getBindingIndex () const
 
GElementRelation getRelation () const
 
 CGRAPH_NO_ALLOWED_COPY (GElement)
 

Private Attributes

CInt left_num_ = 0
 
CStatus cur_status_
 
std::mutex lock_
 
std::condition_variable cv_
 

Friends

class GPipeline
 
class GDynamicEngine
 
class CAllocator
 

Additional Inherited Members

- Public Member Functions inherited from GElement
template<typename TAspect , typename TParam = GAspectDefaultParam, c_enable_if_t< std::is_base_of< GAspect, TAspect >::value, int > = 0, c_enable_if_t< std::is_base_of< GAspectParam, TParam >::value, int > = 0>
GElementaddGAspect (TParam *param=nullptr)
 
template<typename TAspect , typename ... Args, c_enable_if_t< std::is_base_of< GTemplateAspect< Args... >, TAspect >::value, int > = 0>
GElementaddGAspect (Args... args)
 
template<typename T , c_enable_if_t< std::is_base_of< GElementParam, T >::value, int > = 0>
GElementaddEParam (const std::string &key, T *param)
 
CStatus addDependGElements (const std::set< GElement * > &elements)
 
GElementsetName (const std::string &name) override
 
GElementsetLoop (CSize loop)
 
GElementsetLevel (CLevel level)
 
GElementsetVisible (CBool visible)
 
GElementsetBindingIndex (CIndex index)
 
GElementsetTimeout (CMSec timeout, GElementTimeoutStrategy strategy=GElementTimeoutStrategy::AS_ERROR)
 
GElementsetMacro (CBool macro)
 
CBool isGGroup () const
 
CBool isGAdaptor () const
 
CBool isGNode () const
 
GElementState getCurState () const
 
CStatus removeDepend (GElement *element)
 
GElementoperator-- (int) noexcept
 
GElementoperator> (GElement *element)
 
GElementoperator& (GElement *element)
 
GElementoperator* (CSize loop) noexcept
 
template<typename TAspect , typename TParam , c_enable_if_t< std::is_base_of< GAspect, TAspect >::value, int > , c_enable_if_t< std::is_base_of< GAspectParam, TParam >::value, int > >
CGRAPH_NAMESPACE_BEGIN GElementPtr addGAspect (TParam *param)
 
template<typename TAspect , typename ... Args, c_enable_if_t< std::is_base_of< GTemplateAspect< Args... >, TAspect >::value, int > >
GElementPtr addGAspect (Args... args)
 
template<typename T , c_enable_if_t< std::is_base_of< GElementParam, T >::value, int > >
GElementPtr addEParam (const std::string &key, T *param)
 
- Public Member Functions inherited from CObject
 CObject ()=default
 
virtual ~CObject ()=default
 
- Public Member Functions inherited from CDescInfo
virtual const std::string & getName () const
 
const std::string & getSession () const
 
const std::string & getDescription () const
 
virtual auto setDescription (const std::string &description) -> decltype(this)
 
virtual ~CDescInfo ()=default
 
- Protected Attributes inherited from CDescInfo
std::string name_
 
std::string session_
 
std::string description_
 

Detailed Description

template<CInt TriggerNum = 1>
class GSome< TriggerNum >

对于插入的所有GElement,不管实际能不能并行,GSome都会把这些GElement提交到异步任务里面全并发执行(详见run) TriggerNum个GElement执行完成后就退出不再执行剩余的,剩余的置为TIMEOUT(在GElement的fatProcessor里面会不执行直接结束)

Template Parameters
TriggerNum

Constructor & Destructor Documentation

◆ GSome()

template<CInt TriggerNum>
CGRAPH_NAMESPACE_BEGIN GSome< TriggerNum >::GSome
explicitprotected
Here is the call graph for this function:

Member Function Documentation

◆ addElement()

template<CInt TriggerNum>
CStatus GSome< TriggerNum >::addElement ( GElementPtr  element)
finalprotectedvirtual

向group中,添加element信息

Parameters
element
Returns

GSome中插入的元素,必须要有 timeout的设定,如果没有的话,强行写到max值。 用于确保在pipeline run执行完成之前,所有的 element 都会被回收

Reimplemented from GGroup.

Here is the call graph for this function:

◆ checkSuitable()

template<CInt TriggerNum>
CStatus GSome< TriggerNum >::checkSuitable
finalprotectedvirtual

判断当前节点,是否符合执行逻辑。主要用于init的早期阶段

Returns

Reimplemented from GElement.

Here is the call graph for this function:

◆ dump()

template<CInt TriggerNum>
CVoid GSome< TriggerNum >::dump ( std::ostream &  oss)
finalprotectedvirtual

graphviz dump 逻辑

Parameters
oss
Returns

Reimplemented from GElement.

◆ isHold()

template<CInt TriggerNum>
CBool GSome< TriggerNum >::isHold
finalprotectedvirtual

是否持续进行 默认为false,表示执行且仅执行一次

Returns

默认仅返回false 可以根据自己逻辑,来实现"持续循环执行,直到特定条件出现的时候停止"的逻辑

Reimplemented from GElement.

◆ isSerializable()

template<CInt TriggerNum>
CBool GSome< TriggerNum >::isSerializable
finalprotectedvirtual

判断当前元素,是否可以线性执行。默认返回true

Returns

针对group的情况,应该是所有在其中的element 都是可以串行的,才认定为可串行 但是在 region和 multiCondition中,有针对性的判断

Reimplemented from GGroup.

◆ run()

template<CInt TriggerNum>
CStatus GSome< TriggerNum >::run ( )
finalprotectedvirtual

流程处理函数

  1. 并发的执行,其中的所有逻辑信息
  2. 等待 Trigger Num 个element执行完成
  3. 将所有未执行完的element 设置为timeout
  4. 赋返回值

Implements CObject.

Friends And Related Function Documentation

◆ CAllocator

template<CInt TriggerNum = 1>
friend class CAllocator
friend

◆ GDynamicEngine

template<CInt TriggerNum = 1>
friend class GDynamicEngine
friend

◆ GPipeline

template<CInt TriggerNum = 1>
friend class GPipeline
friend

Member Data Documentation

◆ cur_status_

template<CInt TriggerNum = 1>
CStatus GSome< TriggerNum >::cur_status_
private

◆ cv_

template<CInt TriggerNum = 1>
std::condition_variable GSome< TriggerNum >::cv_
private

◆ left_num_

template<CInt TriggerNum = 1>
CInt GSome< TriggerNum >::left_num_ = 0
private

◆ lock_

template<CInt TriggerNum = 1>
std::mutex GSome< TriggerNum >::lock_
private

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