diff options
author | Richard Linden <none@none> | 2013-07-22 11:01:52 -0700 |
---|---|---|
committer | Richard Linden <none@none> | 2013-07-22 11:01:52 -0700 |
commit | e5b51c7f6cfd1ecf374fe8b705f94968a402c573 (patch) | |
tree | 412e7a32665b672956d3eb3e66bd2fcb0817ded4 | |
parent | 075a7bcc980b0ca0d2888d344b6afa8ab5b52d85 (diff) |
BUIDLFIX: moved LLThreadSafeRefCount to proper file
-rwxr-xr-x | indra/llcommon/llevent.h | 1 | ||||
-rwxr-xr-x | indra/llcommon/llpointer.h | 78 | ||||
-rwxr-xr-x | indra/llcommon/llrefcount.h | 85 | ||||
-rwxr-xr-x | indra/llcommon/llthread.h | 2 | ||||
-rwxr-xr-x | indra/llxml/llxmlnode.h | 1 |
5 files changed, 85 insertions, 82 deletions
diff --git a/indra/llcommon/llevent.h b/indra/llcommon/llevent.h index 9d3a7a654a..28ce7de102 100755 --- a/indra/llcommon/llevent.h +++ b/indra/llcommon/llevent.h @@ -29,6 +29,7 @@ #define LL_EVENT_H #include "llsd.h" +#include "llrefcount.h" #include "llpointer.h" namespace LLOldEvents 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 diff --git a/indra/llcommon/llrefcount.h b/indra/llcommon/llrefcount.h index 32ae15435a..3e472d0766 100755 --- a/indra/llcommon/llrefcount.h +++ b/indra/llcommon/llrefcount.h @@ -28,6 +28,7 @@ #include <boost/noncopyable.hpp> #include <boost/intrusive_ptr.hpp> +#include "llmutex.h" #define LL_REF_COUNT_DEBUG 0 #if LL_REF_COUNT_DEBUG @@ -87,22 +88,100 @@ private: #endif }; + +//============================================================================ + +// 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 * this allows you to use boost::intrusive_ptr with any LLRefCount-derived type */ +/** + * 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(LLRefCount* p) + inline void intrusive_ptr_add_ref(LLThreadSafeRefCount* p) { p->ref(); } - inline void intrusive_ptr_release(LLRefCount* p) + inline void intrusive_ptr_release(LLThreadSafeRefCount* p) { - p->unref(); + p->unref(); + } + + inline void intrusive_ptr_add_ref(LLRefCount* p) + { + p->ref(); + } + + inline void intrusive_ptr_release(LLRefCount* p) + { + p->unref(); } }; + #endif diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index c2c6b8e7ac..d7abdc4970 100755 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -32,7 +32,7 @@ #include "apr_thread_cond.h" #include "boost/intrusive_ptr.hpp" #include "llmutex.h" -#include "llpointer.h" +#include "llrefcount.h" LL_COMMON_API void assert_main_thread(); diff --git a/indra/llxml/llxmlnode.h b/indra/llxml/llxmlnode.h index d7681c54a0..339bfa924d 100755 --- a/indra/llxml/llxmlnode.h +++ b/indra/llxml/llxmlnode.h @@ -38,6 +38,7 @@ #include <map> #include "indra_constants.h" +#include "llrefcount.h" #include "llpointer.h" #include "llstring.h" #include "llstringtable.h" |