/* * ===================================================================================== * * Filename: reqrep_center.h * * Description: * * Version: 1.0 * Created: 2021年04月01日 14时09分13秒 * Revision: none * Compiler: gcc * * Author: Li Chao (), * Organization: * * ===================================================================================== */ #ifndef REQREP_CENTER_US3RBM60 #define REQREP_CENTER_US3RBM60 #include "defs.h" #include "socket.h" #include #include #include class ReqRepCenter { class Socket : public ShmSocket { public: Socket(ShmSocket::Shm &shm) : ShmSocket(shm, &kBHTopicReqRepCenter, 1000) {} using ShmSocket::shm; }; Socket socket_; ShmSocket::Shm &shm() { return socket_.shm(); } struct ProcInfo { std::string proc_id_; // unique name std::string server_mqid_; std::string ext_info_; // maybe json. uint64_t timestamp_ = 0; }; typedef std::string Dests; std::mutex mutex_; std::unordered_map topic_mq_; std::unordered_map procs_; public: ReqRepCenter(ShmSocket::Shm &shm) : socket_(shm) {} ReqRepCenter() : ReqRepCenter(BHomeShm()) {} ~ReqRepCenter() { Stop(); } bool Start(const int nworker = 2); bool Stop() { return socket_.Stop(); } }; #endif // end of include guard: REQREP_CENTER_US3RBM60