| | |
| | | #ifndef PUBSUB_4KGRA997 |
| | | #define PUBSUB_4KGRA997 |
| | | |
| | | #include "shm.h" |
| | | #include "socket.h" |
| | | #include <mutex> |
| | | #include <set> |
| | | #include <unordered_map> |
| | | |
| | | namespace bhome_shm { |
| | | namespace bhome_shm |
| | | { |
| | | |
| | | bool Subscribe(const std::string &topic); |
| | | |
| | | // publish/subcribe manager. |
| | | class BusManager |
| | | { |
| | | SharedMemory &shm_; |
| | | ShmSocket socket_; |
| | | std::mutex mutex_; |
| | | typedef std::set<MQId> Clients; |
| | | std::unordered_map<std::string, Clients> records_; |
| | | |
| | | public: |
| | | BusManager(SharedMemory &shm); |
| | | BusManager(); |
| | | ~BusManager() { Stop(); } |
| | | bool Start(const int nworker = 2); |
| | | bool Stop() { return socket_.Stop(); } |
| | | }; |
| | | |
| | | } // namespace bhome_shm |
| | | |
| | | #endif // end of include guard: PUBSUB_4KGRA997 |