diff options
author | prep <prep@lindenlab.com> | 2011-09-14 10:41:52 -0400 |
---|---|---|
committer | prep <prep@lindenlab.com> | 2011-09-14 10:41:52 -0400 |
commit | df40eca093b1a238daea9cd23c44f6e39719bf51 (patch) | |
tree | 205c15512a7fa363ebcea0de8e3ce16a3a58ca38 /indra/llcommon/llsingleton.h | |
parent | 4efca483d7dc8c8a50ebe247c6c163c263ed20f5 (diff) | |
parent | a250df980b3f37e245d30e51ab65831ae1de0ce0 (diff) |
merge
Diffstat (limited to 'indra/llcommon/llsingleton.h')
-rw-r--r-- | indra/llcommon/llsingleton.h | 24 |
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; |