fix a deadlock or sporadic crash during shutdown

This commit is contained in:
Sven Czarnian
2021-08-19 08:01:22 +02:00
parent 25c6a1fa86
commit d06ec49b2e
5 changed files with 57 additions and 19 deletions

View File

@@ -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;
}