| | |
| | | } |
| | | std::unique_ptr<TopicNode> &ProcNodePtr() |
| | | { |
| | | static bool init = GlobalInit(BHomeShm()); |
| | | auto InitLog = []() { |
| | | auto id = GetProcExe(); |
| | | char path[200] = {0}; |
| | | sprintf(path, "/tmp/bhshmq_node_%s.log", id.c_str()); |
| | | ns_log::AddLog(path); |
| | | return true; |
| | | }; |
| | | static bool init_log = InitLog(); |
| | | static std::unique_ptr<TopicNode> ptr(new TopicNode(BHomeShm())); |
| | | static std::mutex mtx; |
| | | std::lock_guard<std::mutex> lk(mtx); |
| | | |
| | | static std::unique_ptr<TopicNode> ptr; |
| | | if (!ptr && GlobalInit(BHomeShm())) { |
| | | auto InitLog = []() { |
| | | auto id = GetProcExe(); |
| | | char path[200] = {0}; |
| | | sprintf(path, "/tmp/bhshmq_node_%s.log", id.c_str()); |
| | | ns_log::AddLog(path); |
| | | return true; |
| | | }; |
| | | static bool init_log = InitLog(); |
| | | ptr.reset(new TopicNode(BHomeShm())); |
| | | } |
| | | return ptr; |
| | | } |
| | | TopicNode &ProcNode() |
| | |
| | | return false; |
| | | } |
| | | MsgOut msg_reply; |
| | | auto &ptr = ProcNodePtr(); |
| | | if (!ptr) { |
| | | SetLastError(eNotFound, "center not started."); |
| | | return 0; |
| | | } |
| | | |
| | | return (ProcNode().*mfunc)(input, msg_reply, timeout_ms) && |
| | | PackOutput(msg_reply, reply, reply_len); |
| | | } |