| | |
| | | */ |
| | | #include "topic_node.h" |
| | | #include "bh_util.h" |
| | | #include "sleeper.h" |
| | | #include <chrono> |
| | | #include <list> |
| | | |
| | |
| | | |
| | | TopicNode::~TopicNode() |
| | | { |
| | | LOG_DEBUG() << "~TopicNode()"; |
| | | Stop(); |
| | | } |
| | | |
| | |
| | | } |
| | | void TopicNode::Stop() |
| | | { |
| | | LOG_DEBUG() << "Node Stopping"; |
| | | for (auto &p : sockets_) { p->Stop(); } |
| | | LOG_INFO() << "Node Stopped"; |
| | | } |
| | | |
| | | bool TopicNode::Register(ProcInfo &proc, MsgCommonReply &reply_body, const int timeout_ms) |
| | |
| | | } |
| | | BHMsgHead head; |
| | | std::string body; |
| | | FibUSleeper sleeper(1000 * 10); |
| | | auto end_time = steady_clock::now() + milliseconds(timeout_ms); |
| | | while (!server_buffer_->Read(head, body)) { |
| | | if (steady_clock::now() < end_time) { |
| | | robust::QuickSleep(); |
| | | sleeper.Sleep(); |
| | | } else { |
| | | return false; |
| | | } |
| | |
| | | |
| | | BHMsgHead head; |
| | | std::string body; |
| | | FibUSleeper sleeper(1000 * 10); |
| | | auto end_time = steady_clock::now() + milliseconds(timeout_ms); |
| | | while (!sub_buffer_->Read(head, body)) { |
| | | if (steady_clock::now() < end_time) { |
| | | robust::QuickSleep(); |
| | | sleeper.Sleep(); |
| | | } else { |
| | | return false; |
| | | } |