lichao
2021-03-31 2e99e5311d1b9a53cca17008452cbe49e2af7234
src/pubsub.h
@@ -18,13 +18,10 @@
#ifndef PUBSUB_4KGRA997
#define PUBSUB_4KGRA997
#include "shm_queue.h"
#include <atomic>
#include "socket.h"
#include <mutex>
#include <set>
#include <thread>
#include <unordered_map>
#include <vector>
namespace bhome_shm
{
@@ -33,21 +30,17 @@
class BusManager
{
   SharedMemory &shm_;
   ShmMsgQueue busq_;
   std::atomic<bool> run_;
   std::vector<std::thread> workers_;
   ShmSocket socket_;
   std::mutex mutex_;
   typedef std::set<MQId> Clients;
   std::unordered_map<std::string, Clients> records_;
   bool StopNoLock();
   void OnMsg(MsgI &msg);
public:
   BusManager(SharedMemory &shm);
   ~BusManager();
   BusManager();
   ~BusManager() { Stop(); }
   bool Start(const int nworker = 2);
   bool Stop();
   bool Stop() { return socket_.Stop(); }
};
} // namespace bhome_shm