From 34cd75f77d0ca94dbdba4e6cc9451fe4d33e78b3 Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期三, 19 五月 2021 19:14:13 +0800 Subject: [PATCH] add api BHQueryProcs. --- src/topic_node.h | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/src/topic_node.h b/src/topic_node.h index 1dfbf43..1bb3611 100644 --- a/src/topic_node.h +++ b/src/topic_node.h @@ -46,6 +46,7 @@ bool Heartbeat(ProcInfo &proc, MsgCommonReply &reply_body, const int timeout_ms); bool Heartbeat(const int timeout_ms); bool QueryTopicAddress(BHAddress &dest, MsgQueryTopic &query, MsgQueryTopicReply &reply_body, const int timeout_ms); + bool QueryProcs(BHAddress &dest, MsgQueryProc &query, MsgQueryProcReply &reply_body, const int timeout_ms); // topic rpc server typedef std::function<bool(const std::string &client_proc_id, const MsgRequestTopic &request, MsgRequestTopicReply &reply)> ServerSyncCB; @@ -163,6 +164,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