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

Method run

tutorial/MyGNode/MySendMessageNode.h:17–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15class MySendMessageNode : public CGraph::GNode {
16public:
17 CStatus run() override {
18 /**
19 * 在 v3.1.2 版本,修改了message的使用方法
20 * 仅通过 std::shared_ptr<T> 传递参数
21 */
22 std::shared_ptr<MyMessageParam> mp(new MyMessageParam());
23
24 mp->num = (num_++) * 10;
25 mp->info = "this is a test send info, num = " + std::to_string(mp->num);
26 /**
27 * 在v2.5.1版本,增加了 GMessagePushStrategy 策略,不兼容之前版本
28 * 如果需要跟之前逻辑保持一致,直接设定 CGraph::GMessagePushStrategy::WAIT 即可
29 * 其他的选项功能,参考 URingBufferPushStrategy(GMessagePushStrategy的别名) 的说明
30 */
31 CStatus status = CGRAPH_SEND_MPARAM(MyMessageParam, "send-recv", mp, CGraph::GMessagePushStrategy::WAIT)
32 return status;
33 }
34
35private:
36 int num_ = 0;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected