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

Function tutorial_suspend

tutorial/T20-Suspend.cpp:14–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12using namespace CGraph;
13
14void tutorial_suspend() {
15 GPipelinePtr pipeline = GPipelineFactory::create();
16 GElementPtr a, b, c, d = nullptr;
17
18 CStatus status = pipeline->registerGElement<MyNode1>(&a, {}, "nodeA");
19 status += pipeline->registerGElement<MyNode2>(&b, {a}, "nodeB", 3);
20 status += pipeline->registerGElement<MyNode1>(&c, {a}, "nodeC", 3);
21 status += pipeline->registerGElement<MyNode2>(&d, {b, c}, "nodeD");
22 if (!status.isOK()) {
23 std::cout << status.getInfo() << std::endl;
24 return; // 使用时,请对所有CGraph接口的返回值做判定。今后tutorial例子中省略该操作。
25 }
26
27 status += pipeline->init();
28
29 CGRAPH_ECHO("pipeline async run, BEGIN.");
30 auto result = pipeline->asyncRun();
31 CGRAPH_SLEEP_MILLISECOND(2600)
32
33 CGRAPH_ECHO("pipeline async run, SUSPEND.");
34 status += pipeline->suspend(); // 暂停执行,保留当前pipeline内部所有参数信息和状态信息
35
36 CGRAPH_SLEEP_MILLISECOND(7200)
37 CGRAPH_ECHO("pipeline async run, RESUME after 7200ms.");
38 status += pipeline->resume(); // 暂停一段时间后,恢复执行
39
40 result.wait(); // 等待pipeline异步执行结束
41 pipeline->destroy();
42
43 GPipelineFactory::remove(pipeline);
44}
45
46
47int main () {

Callers 1

mainFunction · 0.70

Calls 10

createFunction · 0.85
CGRAPH_ECHOFunction · 0.85
removeFunction · 0.85
isOKMethod · 0.80
suspendMethod · 0.80
resumeMethod · 0.80
waitMethod · 0.80
initMethod · 0.45
asyncRunMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected