aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon/llmemory.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llcommon/llmemory.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/linden/indra/llcommon/llmemory.h b/linden/indra/llcommon/llmemory.h
index e1af7ba..c10661a 100644
--- a/linden/indra/llcommon/llmemory.h
+++ b/linden/indra/llcommon/llmemory.h
@@ -419,6 +419,31 @@ protected:
419// Foo* instance = FooSingleton::getInstance(); 419// Foo* instance = FooSingleton::getInstance();
420// 420//
421// As currently written, it is not thread-safe. 421// As currently written, it is not thread-safe.
422#if LL_WINDOWS && _MSC_VER < 1400 // this is Visual C++ 2003 or earlier
423// workaround for VC7 compiler bug
424// adapted from http://www.codeproject.com/KB/tips/VC2003MeyersSingletonBug.aspx
425// our version doesn't introduce a nested struct so that you can still declare LLSingleton<MyClass>
426// a friend and hide your constructor
427
428template <typename T>
429class LLSingleton
430{
431public:
432 static T* getInstance()
433 {
434 LLSingleton<T> singleton;
435 return singleton.get();
436 }
437private:
438 T* get()
439 {
440 static T instance;
441 return &instance;
442 }
443
444};
445#else
446
422template <typename T> 447template <typename T>
423class LLSingleton 448class LLSingleton
424{ 449{
@@ -430,6 +455,8 @@ public:
430 } 455 }
431}; 456};
432 457
458#endif
459
433//---------------------------------------------------------------------------- 460//----------------------------------------------------------------------------
434 461
435// Return the resident set size of the current process, in bytes. 462// Return the resident set size of the current process, in bytes.