fix a deadlock or sporadic crash during shutdown
This commit is contained in:
@@ -13,8 +13,23 @@
|
||||
|
||||
using namespace aman;
|
||||
|
||||
static zmq::context_t __context(2);
|
||||
ZmqContext::ZmqContext() : m_context() { }
|
||||
|
||||
void ZmqContext::initialize() {
|
||||
if (nullptr == this->m_context)
|
||||
this->m_context = std::make_unique<zmq::context_t>(2);
|
||||
}
|
||||
|
||||
void ZmqContext::deinitialize() {
|
||||
if (nullptr != this->m_context)
|
||||
this->m_context = std::unique_ptr<zmq::context_t>();
|
||||
}
|
||||
|
||||
zmq::context_t& ZmqContext::context() {
|
||||
return __context;
|
||||
return *this->m_context;
|
||||
}
|
||||
|
||||
ZmqContext& ZmqContext::instance() {
|
||||
static ZmqContext __instance;
|
||||
return __instance;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user