GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — CGraph/tutorial/T01-Simple.cpp at main · feiyunwill/CGraph Expand file tree/ Copy pathT01-Simple.cppMore file actions 58 lines (47 loc) · 2.16 KB / Copy pathT01-Simple.cppFile metadata and controls58 lines (47 loc) · 2.16 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 /*************************** @Author: Chunel @Contact: [email protected] @File: T01-Simple.cpp @Time: 2021/5/4 4:09 下午 @Desc: 本例主要演示,GPipeline注册和添加依赖关系的流程 ***************************/ #include "MyGNode/MyNode1.h" #include "MyGNode/MyNode2.h" using namespace CGraph; void tutorial_simple() { /* 创建图对应的pipeline */ GPipelinePtr pipeline = GPipelineFactory::create(); /* 定义GElementPtr类型的变量 */ GElementPtr a, b, c, d = nullptr; /** * 注册节点,其中MyNode1和MyNode2必须为GNode的子类,否则无法通过编译。 * status+= 操作,可以用于记录链路异常问题 * */ CStatus status = pipeline->registerGElement<MyNode1>(&a, {}, "nodeA"); // 将名为nodeA,无执行依赖的node信息,注册入pipeline中 status += pipeline->registerGElement<MyNode2>(&b, {a}, "nodeB"); // 将名为nodeB,依赖a执行的node信息,注册入pipeline中 status += pipeline->registerGElement<MyNode1>(&c, {a}, "nodeC"); status += pipeline->registerGElement<MyNode2>(&d, {b, c}, "nodeD"); // 将名为nodeD,依赖{b,c}执行的node信息,注册入pipeline中 if (!status.isOK()) { return; // 使用时,请对所有CGraph接口的返回值做判定。今后tutorial例子中省略该操作。 } /** UThreadPoolConfig config; // (可选)推荐根据自己设定的dag逻辑,来配置调度信息 config.default_thread_size_ = 2; config.secondary_thread_size_ = 0; // 更多配置信息,请参考 UThreadPoolDefine.h 中的描述 pipeline->setUniqueThreadPoolConfig(config); */ /* 图信息初始化,准备开始计算 */ status += pipeline->init(); /* 运行流图信息。初始化后,支持多次循环计算 */ for (int i = 0; i < 3; i++) { status = pipeline->run(); CGRAPH_ECHO("==== tutorial_simple, loop : [%d], and run status = [%d].", i + 1, status.getCode()); } /* 图信息逆初始化,准备结束计算 */ status += pipeline->destroy(); GPipelineFactory::remove(pipeline); } int main () { tutorial_simple(); return 0; } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |