diff options
author | Ptolemy <ptolemy@lindenlab.com> | 2021-10-29 15:11:42 -0700 |
---|---|---|
committer | Ptolemy <ptolemy@lindenlab.com> | 2021-10-29 15:11:42 -0700 |
commit | 1be8a8d10bd3542b0b5c2943a508509c5cfcf3ef (patch) | |
tree | a4bd2bdddb24ae0b443878b0337e77787d3fea40 /indra/llcommon/llsingleton.h | |
parent | 61bca72d37f695ee15897ddc3b9215c969ecf648 (diff) | |
parent | 68b75be652575ff301172b7b19522d4f0494bdf0 (diff) |
Fix merge conflict
Diffstat (limited to 'indra/llcommon/llsingleton.h')
-rw-r--r-- | indra/llcommon/llsingleton.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index 2e43a3cbed..10a8ecfedb 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -839,4 +839,30 @@ private: \ /* LLSINGLETON() is carefully implemented to permit exactly this */ \ LLSINGLETON_C11(DERIVED_CLASS) {} +// Relatively unsafe singleton implementation that is much faster +// and simpler than LLSingleton, but has no dependency tracking +// or inherent thread safety and requires manual invocation of +// createInstance before first use. +template<class T> +class LLSimpleton +{ +public: + static T* sInstance; + + static void createInstance() + { + llassert(sInstance == nullptr); + sInstance = new T(); + } + + static inline T* getInstance() { return sInstance; } + static inline T& instance() { return *getInstance(); } + static inline bool instanceExists() { return sInstance != nullptr; } + + static void deleteSingleton() { + delete sInstance; + sInstance = nullptr; + } +}; + #endif |