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

Method daemonTask

tutorial/MyGDaemon/MyParamDaemon.h:18–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16class MyParamDaemon : public CGraph::GDaemon {
17public:
18 CVoid daemonTask(CGraph::GDaemonParamPtr param) override {
19 /**
20 * 从注册的pipeline中获取参数信息
21 * 注意,这里是GParam类型
22 */
23 auto* myParam = CGRAPH_GET_GPARAM_WITH_NO_EMPTY(MyParam, "param1")
24 // 根据实际情况,选择不上锁,或者上读/写锁
25 CGraph::CGRAPH_ECHO("----> [MyParamDaemon] iCount is [%d], just suppose this value is show on dashboard every [%ld] ms",
26 myParam->iCount, this->getInterval());
27
28 /**
29 * 获取任务外部传入的参数信息
30 * 需要强转成外部传入的类型,方法如下:
31 */
32 auto connParam = dynamic_cast<MyConnParam *>(param);
33 if (connParam) {
34 // 对应有参数传入的分支
35 CGraph::CGRAPH_ECHO("----> [MyParamDaemon] input param, address is [%s : %d]",
36 connParam->ip_.c_str(), connParam->port_);
37 } else {
38 // 对应无参数传入的分支
39 CGraph::CGRAPH_ECHO("----> [MyParamDaemon] no input param info.");
40 }
41 }
42};
43
44

Callers

nothing calls this directly

Calls 2

CGRAPH_ECHOFunction · 0.85
getIntervalMethod · 0.80

Tested by

no test coverage detected