MCPcopy Create free account
hub / github.com/ChunelFeng/CGraph / tutorial_some

Function tutorial_some

tutorial/T23-Some.cpp:14–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12using namespace CGraph;
13
14void tutorial_some() {
15 GPipelinePtr pipeline = GPipelineFactory::create();
16 GElementPtr a, b_some, c, d = nullptr;
17
18 /**
19 * 创建一个类型为GSome的组,其中注入3个异步节点,其中有[1]个执行完成,则GSome执行结束
20 * 也就是说,这个 GSome 会执行1s后,就往下继续执行。效果类似增强版本的弱依赖
21 * 需要注意的是,当前GSome执行完成,并且今后后续的element后,
22 * 内部的节点仍会继续执行,故如果在节点内做参数处理,请注意考虑后续影响
23 * 当前pipeline的run()方法,会等到内部的内部节点全部执行完成后,才结束
24 */
25 b_some = pipeline->createGGroup<GSome<1>>({
26 pipeline->createGNode<MyNode1>(GNodeInfo("nodeB1")),
27 pipeline->createGNode<MyNode2>(GNodeInfo("nodeB2")),
28 pipeline->createGNode<MyNode2>(GNodeInfo("nodeB3"))
29 });
30
31 CStatus status = pipeline->registerGElement<MyNode1>(&a, {}, "nodeA");
32 status += pipeline->registerGGroup(&b_some, {a}, "someB");
33 status += pipeline->registerGElement<MyNode1>(&c, {b_some}, "nodeC");
34 status += pipeline->registerGElement<MyNode2>(&d, {c}, "nodeD");
35 if (!status.isOK()) {
36 return;
37 }
38
39 status += pipeline->process();
40 CGRAPH_ECHO("pipeline run finished, error code is [%d]", status.getCode());
41
42 GPipelineFactory::clear();
43}
44
45
46int main() {

Callers 1

mainFunction · 0.85

Calls 8

createFunction · 0.85
GNodeInfoClass · 0.85
CGRAPH_ECHOFunction · 0.85
registerGGroupMethod · 0.80
isOKMethod · 0.80
getCodeMethod · 0.80
clearFunction · 0.50
processMethod · 0.45

Tested by

no test coverage detected