From 5657dca25451cfb63a90a3908db0c464fe3f343d Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期一, 29 三月 2021 14:16:49 +0800
Subject: [PATCH] add protobuf; refactor.

---
 src/pubsub.h |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/src/pubsub.h b/src/pubsub.h
index 0d7f4f0..0628216 100644
--- a/src/pubsub.h
+++ b/src/pubsub.h
@@ -18,12 +18,31 @@
 #ifndef PUBSUB_4KGRA997
 #define PUBSUB_4KGRA997
 
-#include "shm.h"
+#include "shm_queue.h"
+#include <thread>
+#include <atomic>
+#include <mutex>
+#include <vector>
 
 namespace bhome_shm {
 
-bool Subscribe(const std::string &topic);
-	
+// publish/subcribe manager.
+class BusManager
+{
+    ShmMsgQueue busq_;
+    std::atomic<bool> run_;
+    std::vector<std::thread> workers_;
+    std::mutex mutex_;
+
+    bool StopNoLock();
+public:
+    BusManager(SharedMemory &shm);
+    ~BusManager();
+    bool Start(const int nworker = 2);
+    bool Stop();
+};
+
+
 } // namespace bhome_shm
 
 #endif // end of include guard: PUBSUB_4KGRA997

--
Gitblit v1.8.0