summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llcommon/llsingleton.h29
1 files changed, 16 insertions, 13 deletions
diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h
index 314ee2caa8..0c11e54910 100644
--- a/indra/llcommon/llsingleton.h
+++ b/indra/llcommon/llsingleton.h
@@ -654,20 +654,10 @@ private:
typedef LLSingleton<DERIVED_TYPE> super;
using typename super::LockStatic;
-public:
- using super::deleteSingleton;
- using super::instanceExists;
- using super::wasDeleted;
-
// Passes arguments to DERIVED_TYPE's constructor and sets appropriate
- // states. We'd rather return a reference than a pointer, but the test for
- // redundant calls makes that awkward. The compiler, unaware that
- // logerrs() won't return, requires that that alternative return
- // *something*. But what? It can't be a dummy static instance because
- // there should be only one instance of any LLSingleton subclass! Easier
- // to allow that case to return nullptr.
+ // states, returning a pointer to the new instance.
template <typename... Args>
- static DERIVED_TYPE* initParamSingleton(Args&&... args)
+ static DERIVED_TYPE* initParamSingleton_(Args&&... args)
{
// In case racing threads both call initParamSingleton() at the same
// time, serialize them. One should initialize; the other should see
@@ -709,7 +699,7 @@ public:
[&](){
super::loginfos(super::template classname<DERIVED_TYPE>().c_str(),
"::initParamSingleton() on main thread");
- return initParamSingleton(std::forward<Args>(args)...);
+ return initParamSingleton_(std::forward<Args>(args)...);
});
super::loginfos(super::template classname<DERIVED_TYPE>().c_str(),
"::initParamSingleton() returning on requesting thread");
@@ -717,6 +707,19 @@ public:
}
}
+public:
+ using super::deleteSingleton;
+ using super::instanceExists;
+ using super::wasDeleted;
+
+ /// initParamSingleton() constructs the instance, returning a reference.
+ /// Pass whatever arguments are required to construct DERIVED_TYPE.
+ template <typename... Args>
+ static DERIVED_TYPE& initParamSingleton(Args&&... args)
+ {
+ return *initParamSingleton_(std::forward<Args>(args)...);
+ }
+
static DERIVED_TYPE* getInstance()
{
// In case racing threads call getInstance() at the same moment as