diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2019-12-12 16:19:23 -0500 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2020-03-25 15:28:17 -0400 |
commit | 68505edf25f5013edfe7197405228bee9a299b68 (patch) | |
tree | 6ec9f158eaac7e37ff86f1780955cd4b7b82d9ec | |
parent | a6f5e55d42f417ea8bc565e473354b64c192802d (diff) |
DRTVWR-494: LLParamSingleton<T>::initParamSingleton() now returns T*.
So does LLLockedSingleton<T>::construct().
-rw-r--r-- | indra/llcommon/llsingleton.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index 4f3b8ceb38..39d0e9b013 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -650,9 +650,15 @@ public: using super::instanceExists; using super::wasDeleted; - // Passes arguments to DERIVED_TYPE's constructor and sets appropriate states + // 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. template <typename... Args> - static void 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 @@ -664,10 +670,12 @@ public: super::logerrs("Tried to initialize singleton ", super::template classname<DERIVED_TYPE>().c_str(), " twice!"); + return nullptr; } else { super::constructSingleton(lk, std::forward<Args>(args)...); + return lk->mInstance; } } @@ -740,9 +748,9 @@ public: using super::instanceExists; using super::wasDeleted; - static void construct() + static DT* construct() { - super::initParamSingleton(); + return super::initParamSingleton(); } }; |