From e54b8e58780c7d9f37b06cc4e1dc88badb2129c9 Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期二, 18 五月 2021 17:02:21 +0800 Subject: [PATCH] remove sync recv, node cache msgs for sync recv. --- src/topic_node.h | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/src/topic_node.h b/src/topic_node.h index 1dfbf43..81bf718 100644 --- a/src/topic_node.h +++ b/src/topic_node.h @@ -163,6 +163,32 @@ int proc_index_ = -1; TopicQueryCache topic_query_cache_; + + class RecvQ + { + public: + void Write(BHMsgHead &&head, std::string &&body) { q_.push_back({std::move(head), std::move(body)}); } + bool Read(BHMsgHead &head, std::string &body) + { + if (q_.empty()) { + return false; + } else { + head = std::move(q_.front().head); + body = std::move(q_.front().body); + q_.pop_front(); + return true; + } + } + + private: + struct MsgData { + BHMsgHead head; + std::string body; + }; + std::deque<MsgData> q_; + }; + Synced<RecvQ> server_buffer_; + Synced<RecvQ> sub_buffer_; }; #endif // end of include guard: TOPIC_NODE_YVKWA6TF -- Gitblit v1.8.0