summaryrefslogtreecommitdiff
path: root/indra/llcommon/llsingleton.h
diff options
context:
space:
mode:
authorLeslie Linden <leslie@lindenlab.com>2011-09-15 16:23:44 -0700
committerLeslie Linden <leslie@lindenlab.com>2011-09-15 16:23:44 -0700
commit9e00dc0cc0af26d85d5613e8bddc03067e37c7d2 (patch)
tree42de09ea97f45a80c1969c986fe313eb2a7dc192 /indra/llcommon/llsingleton.h
parent03e965a7324ca9ecc3d99faf27e2ea4d7b2fbc52 (diff)
parent1d3f6ef432b714a7659e9a5ee62377e56a843006 (diff)
Merge from viewer-experience-merge
Diffstat (limited to 'indra/llcommon/llsingleton.h')
-rw-r--r--indra/llcommon/llsingleton.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h
index 00757be277..49d99f2cd0 100644
--- a/indra/llcommon/llsingleton.h
+++ b/indra/llcommon/llsingleton.h
@@ -114,8 +114,7 @@ private:
~SingletonInstanceData()
{
- SingletonInstanceData& data = getData();
- if (data.mInitState != DELETED)
+ if (mInitState != DELETED)
{
deleteSingleton();
}
@@ -130,7 +129,26 @@ public:
data.mInitState = DELETED;
}
- // Can be used to control when the singleton is deleted. Not normally needed.
+ /**
+ * @brief Immediately delete the singleton.
+ *
+ * A subsequent call to LLProxy::getInstance() will construct a new
+ * instance of the class.
+ *
+ * LLSingletons are normally destroyed after main() has exited and the C++
+ * runtime is cleaning up statically-constructed objects. Some classes
+ * derived from LLSingleton have objects that are part of a runtime system
+ * that is terminated before main() exits. Calling the destructor of those
+ * objects after the termination of their respective systems can cause
+ * crashes and other problems during termination of the project. Using this
+ * method to destroy the singleton early can prevent these crashes.
+ *
+ * An example where this is needed is for a LLSingleton that has an APR
+ * object as a member that makes APR calls on destruction. The APR system is
+ * shut down explicitly before main() exits. This causes a crash on exit.
+ * Using this method before the call to apr_terminate() and NOT calling
+ * getInstance() again will prevent the crash.
+ */
static void deleteSingleton()
{
delete getData().mSingletonInstance;