| | |
| | | #ifndef REQREP_ACEH09NK |
| | | #define REQREP_ACEH09NK |
| | | |
| | | #include "bh_util.h" |
| | | #include "defs.h" |
| | | #include "msg.h" |
| | | #include "socket.h" |
| | |
| | | bool QueryRPCTopic(const std::string &topic, bhome::msg::BHAddress &addr, const int timeout_ms); |
| | | std::unordered_map<std::string, RecvCB> async_cbs_; |
| | | |
| | | std::pair<std::string, bhome::msg::BHAddress> tmp_cache_; |
| | | typedef bhome_msg::BHAddress Address; |
| | | class TopicCache |
| | | { |
| | | class Impl |
| | | { |
| | | typedef std::unordered_map<std::string, Address> Store; |
| | | Store store_; |
| | | |
| | | public: |
| | | bool Find(const std::string &topic, Address &addr) |
| | | { |
| | | auto pos = store_.find(topic); |
| | | if (pos != store_.end()) { |
| | | addr = pos->second; |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | bool Update(const std::string &topic, const Address &addr) |
| | | { |
| | | store_[topic] = addr; |
| | | return true; |
| | | } |
| | | }; |
| | | Synced<Impl> impl_; |
| | | // Impl &impl() |
| | | // { |
| | | // thread_local Impl impl; |
| | | // return impl; |
| | | // } |
| | | |
| | | public: |
| | | bool Find(const std::string &topic, Address &addr) { return impl_->Find(topic, addr); } |
| | | bool Update(const std::string &topic, const Address &addr) { return impl_->Update(topic, addr); } |
| | | }; |
| | | TopicCache topic_cache_; |
| | | }; |
| | | |
| | | class SocketReply : private ShmSocket |