Commit 258c14db authored by Dominik Charousset's avatar Dominik Charousset

fix singleton_manager::lazy_get

fixed an issue with lazy_get that could cause method invocation on
uninitialized singletons
parent 89a332a0
......@@ -100,9 +100,13 @@ class singleton_manager {
T* result = ptr.load();
while (result == nullptr) {
auto tmp = T::create_singleton();
if (ptr.compare_exchange_weak(result, tmp)) {
// double check if singleton is still undefined
if (ptr.load() == nullptr) {
tmp->initialize();
result = tmp;
if (ptr.compare_exchange_weak(result, tmp)) {
result = tmp;
}
else tmp->destroy();
}
else tmp->dispose();
}
......
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 to comment