Skip to content
Snippets Groups Projects
Commit 794072c1 authored by Nat Goodspeed's avatar Nat Goodspeed
Browse files

DRTVWR-494: Streamline LLSingleton state machine.

The CONSTRUCTED state was only briefly set between constructSingleton() and
finishInitializing(). But as no consumer code is executed between setting
CONSTRUCTED and setting INITIALIZING, it was impossible to reach the switch
statement in either getInstance() method in state CONSTRUCTED. So there was no
point in state CONSTRUCTED. Remove it.

With CONSTRUCTED gone, we only ever call finishInitializing() right after
constructSingleton(). Merge finishInitializing() into constructSingleton().
parent b080b06b
No related branches found
No related tags found
No related merge requests found
......@@ -57,7 +57,6 @@ class LLSingletonBase: private boost::noncopyable
{
UNINITIALIZED = 0, // must be default-initialized state
CONSTRUCTING, // within DERIVED_TYPE constructor
CONSTRUCTED, // finished DERIVED_TYPE constructor
INITIALIZING, // within DERIVED_TYPE::initSingleton()
INITIALIZED, // normal case
DELETED // deleteSingleton() or deleteAll() called
......@@ -355,7 +354,6 @@ class LLSingleton : public LLSingletonBase
{
sData.mInstance = new DERIVED_TYPE(std::forward<Args>(args)...);
// we have called constructor, have not yet called initSingleton()
sData.mInitState = CONSTRUCTED;
}
catch (const std::exception& err)
{
......@@ -373,10 +371,7 @@ class LLSingleton : public LLSingletonBase
// propagate the exception
throw;
}
}
static void finishInitializing()
{
// getInstance() calls are from within initSingleton()
sData.mInitState = INITIALIZING;
try
......@@ -506,11 +501,6 @@ class LLSingleton : public LLSingletonBase
case UNINITIALIZED:
constructSingleton();
// fall through...
case CONSTRUCTED:
// still have to call initSingleton()
finishInitializing();
break;
case INITIALIZING:
......@@ -526,7 +516,6 @@ class LLSingleton : public LLSingletonBase
classname<DERIVED_TYPE>().c_str(),
" -- creating new instance");
constructSingleton();
finishInitializing();
break;
}
......@@ -625,7 +614,6 @@ class LLParamSingleton : public LLSingleton<DERIVED_TYPE>
else
{
super::constructSingleton(std::forward<Args>(args)...);
super::finishInitializing();
}
}
......@@ -648,18 +636,6 @@ class LLParamSingleton : public LLSingleton<DERIVED_TYPE>
" from singleton constructor!");
break;
case super::CONSTRUCTED:
// Should never happen!? The CONSTRUCTED state is specifically to
// navigate through LLSingleton::SingletonInitializer getting
// constructed (once) before LLSingleton::getInstance()'s switch
// on mInitState. But our initParamSingleton() method calls
// constructSingleton() and then calls finishInitializing(), which
// immediately sets INITIALIZING. Why are we here?
super::logerrs("Param singleton ",
super::template classname<DERIVED_TYPE>().c_str(),
"::initSingleton() not yet called");
break;
case super::INITIALIZING:
// As with LLSingleton, explicitly permit circular calls from
// within initSingleton()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment