summaryrefslogtreecommitdiff
path: root/indra/llcommon/llsingleton.h
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2016-09-03 11:30:53 -0400
committerNat Goodspeed <nat@lindenlab.com>2016-09-03 11:30:53 -0400
commitc71e6222295a1fb183436b5d67c21bffddfaefa6 (patch)
tree1a46a88e39875106276dd8af70d394a772038b53 /indra/llcommon/llsingleton.h
parent4af7e496b489aaddea60453f40fd422ef5381a2d (diff)
MAINT-5232: Add DEBUG logging to LLSingleton dependency tracking.
Specifically, add DEBUG logging to the code that maintains the stack of LLSingletons currently being initialized. This involves passing LLSingletonBase's constructor the name of LLSingleton's template parameter subclass, since during that constructor typeid(*this).name() will only produce "LLSingletonBase". Also add logdebugs() and oktolog() helper functions.
Diffstat (limited to 'indra/llcommon/llsingleton.h')
-rw-r--r--indra/llcommon/llsingleton.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h
index 6a7f27bed4..78092fdc11 100644
--- a/indra/llcommon/llsingleton.h
+++ b/indra/llcommon/llsingleton.h
@@ -66,8 +66,10 @@ protected:
} EInitState;
// Base-class constructor should only be invoked by the DERIVED_TYPE
- // constructor.
- LLSingletonBase();
+ // constructor, which passes the DERIVED_TYPE class name for logging
+ // purposes. Within LLSingletonBase::LLSingletonBase, of course the
+ // formula typeid(*this).name() produces "LLSingletonBase".
+ LLSingletonBase(const char* name);
virtual ~LLSingletonBase();
// Every new LLSingleton should be added to/removed from the master list
@@ -87,11 +89,15 @@ protected:
// single C++ scope, else we'd use RAII to track it. But we do know that
// LLSingletonBase's constructor definitely runs just before
// LLSingleton's, which runs just before the specific subclass's.
- void push_initializing();
+ void push_initializing(const char*);
// LLSingleton is, and must remain, the only caller to initSingleton().
// That being the case, we control exactly when it happens -- and we can
// pop the stack immediately thereafter.
void pop_initializing();
+private:
+ // logging
+ static void log_initializing(const char* verb, const char* name);
+protected:
// If a given call to B::getInstance() happens during either A::A() or
// A::initSingleton(), record that A directly depends on B.
void capture_dependency(EInitState);
@@ -281,7 +287,9 @@ private:
};
protected:
- LLSingleton()
+ // Use typeid(DERIVED_TYPE) rather than typeid(*this) because, until our
+ // constructor completes, *this isn't yet a full-fledged DERIVED_TYPE.
+ LLSingleton(): LLSingletonBase(typeid(DERIVED_TYPE).name())
{
// populate base-class function pointer with the static
// deleteSingleton() function for this particular specialization