From d33a69463f1a75134d01191be0b9e1bdd757dd4b Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期五, 30 四月 2021 15:27:59 +0800
Subject: [PATCH] add atomic queue, no lock, unorder.

---
 src/bh_api.cpp |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/bh_api.cpp b/src/bh_api.cpp
index c4ac9c9..c29afd9 100644
--- a/src/bh_api.cpp
+++ b/src/bh_api.cpp
@@ -8,11 +8,15 @@
 
 namespace
 {
+std::unique_ptr<TopicNode> &ProcNodePtr()
+{
+	static bool init = GlobalInit(BHomeShm());
+	static std::unique_ptr<TopicNode> ptr(new TopicNode(BHomeShm()));
+	return ptr;
+}
 TopicNode &ProcNode()
 {
-	static bool init_bind_msg_shm = MsgI::BindShm(BHomeShm());
-	static TopicNode node(BHomeShm());
-	return node;
+	return *ProcNodePtr();
 }
 
 class TmpPtr : private boost::noncopyable
@@ -320,6 +324,12 @@
 	free(data);
 }
 
+int BHCleanup()
+{
+	ProcNodePtr().reset();
+	return 0;
+}
+
 int BHGetLastError(void **msg, int *msg_len)
 {
 	int ec = 0;

--
Gitblit v1.8.0