Commit 58c86fef by Marcus Winter

mtapi_cpp: used double-checked locking pattern in Node::GetInstance

parent 049b3b00
......@@ -198,13 +198,15 @@ bool Node::IsInitialized() {
Node & Node::GetInstance() {
#if MTAPI_CPP_AUTOMATIC_INITIALIZE
init_mutex.Lock();
if (!IsInitialized()) {
Node::Initialize(
MTAPI_CPP_AUTOMATIC_DOMAIN_ID, MTAPI_CPP_AUTOMATIC_NODE_ID);
atexit(Node::Finalize);
init_mutex.Lock();
if (!IsInitialized()) {
Node::Initialize(
MTAPI_CPP_AUTOMATIC_DOMAIN_ID, MTAPI_CPP_AUTOMATIC_NODE_ID);
atexit(Node::Finalize);
}
init_mutex.Unlock();
}
init_mutex.Unlock();
return *node_instance;
#else
if (IsInitialized()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment