From 2e99e5311d1b9a53cca17008452cbe49e2af7234 Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期三, 31 三月 2021 14:05:09 +0800 Subject: [PATCH] add bus socket for manager; refactor. --- src/pubsub.h | 17 +++++------------ 1 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/pubsub.h b/src/pubsub.h index dc3fced..be6521f 100644 --- a/src/pubsub.h +++ b/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 -- Gitblit v1.8.0