/* * ===================================================================================== * * Filename: pubsub.h * * Description: * * Version: 1.0 * Created: 2021年03月24日 18时44分36秒 * Revision: none * Compiler: gcc * * Author: Li Chao (), * Organization: * * ===================================================================================== */ #ifndef PUBSUB_4KGRA997 #define PUBSUB_4KGRA997 #include "shm_queue.h" #include #include #include #include #include #include namespace bhome_shm { // publish/subcribe manager. class BusManager { SharedMemory &shm_; ShmMsgQueue busq_; std::atomic run_; std::vector workers_; std::mutex mutex_; typedef std::set Clients; std::unordered_map records_; bool StopNoLock(); void OnMsg(const BHMsg &msg); public: BusManager(SharedMemory &shm); ~BusManager(); bool Start(const int nworker = 2); bool Stop(); }; } // namespace bhome_shm #endif // end of include guard: PUBSUB_4KGRA997