diff options
author | Richard Linden <none@none> | 2013-07-22 11:04:05 -0700 |
---|---|---|
committer | Richard Linden <none@none> | 2013-07-22 11:04:05 -0700 |
commit | 1ba17a522023a80cd8aeb3beb98f03c23ee3e75c (patch) | |
tree | d0c66376d12d576be631b850931301f68286976b /indra/llcommon/llpointer.h | |
parent | e40065f82c797eab41006a448c838f4f1089a2e8 (diff) | |
parent | e5b51c7f6cfd1ecf374fe8b705f94968a402c573 (diff) |
Automated merge with https://bitbucket.org/lindenlab/viewer-interesting
Diffstat (limited to 'indra/llcommon/llpointer.h')
-rwxr-xr-x | indra/llcommon/llpointer.h | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index 9a0726c338..e09741b0ec 100755 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -214,82 +214,4 @@ private: bool mStayUnique; }; -//============================================================================ - -// see llmemory.h for LLPointer<> definition - -class LL_COMMON_API LLThreadSafeRefCount -{ -public: - static void initThreadSafeRefCount(); // creates sMutex - static void cleanupThreadSafeRefCount(); // destroys sMutex - -private: - static LLMutex* sMutex; - -protected: - virtual ~LLThreadSafeRefCount(); // use unref() - -public: - LLThreadSafeRefCount(); - LLThreadSafeRefCount(const LLThreadSafeRefCount&); - LLThreadSafeRefCount& operator=(const LLThreadSafeRefCount& ref) - { - if (sMutex) - { - sMutex->lock(); - } - mRef = 0; - if (sMutex) - { - sMutex->unlock(); - } - return *this; - } - - void ref() - { - if (sMutex) sMutex->lock(); - mRef++; - if (sMutex) sMutex->unlock(); - } - - S32 unref() - { - llassert(mRef >= 1); - if (sMutex) sMutex->lock(); - S32 res = --mRef; - if (sMutex) sMutex->unlock(); - if (0 == res) - { - delete this; - return 0; - } - return res; - } - S32 getNumRefs() const - { - return mRef; - } - -private: - S32 mRef; -}; - -/** - * intrusive pointer support for LLThreadSafeRefCount - * this allows you to use boost::intrusive_ptr with any LLThreadSafeRefCount-derived type - */ -namespace boost -{ - inline void intrusive_ptr_add_ref(LLThreadSafeRefCount* p) - { - p->ref(); - } - - inline void intrusive_ptr_release(LLThreadSafeRefCount* p) - { - p->unref(); - } -}; #endif |