From 72bffb0807925a156b076b71f78c848a08d27b87 Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期四, 29 四月 2021 10:55:35 +0800 Subject: [PATCH] refactor mutex. --- 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