diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp index 5063cbe7a..596a6dcff 100644 --- a/indra/llaudio/llaudiodecodemgr.cpp +++ b/indra/llaudio/llaudiodecodemgr.cpp @@ -41,6 +41,7 @@ #include "lldir.h" #include "llendianswizzle.h" #include "llassetstorage.h" +#include "llrefcount.h" #include "vorbis/codec.h" #include "vorbis/vorbisfile.h" diff --git a/indra/llcommon/llaprpool.h b/indra/llcommon/llaprpool.h index 4c9f36893..74af351e4 100644 --- a/indra/llcommon/llaprpool.h +++ b/indra/llcommon/llaprpool.h @@ -48,6 +48,7 @@ #include "apr_portable.h" #include "apr_pools.h" #include "llerror.h" +#include "aithreadid.h" extern void ll_init_apr(); diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index d01b43917..19cc720b0 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -523,7 +523,6 @@ void LLPrivateMemoryPoolTester::operator delete[](void* addr) //EVENTUALLY REMOVE THESE: #include "llpointer.h" -#include "llrefcount.h" #include "llsingleton.h" #include "llsafehandle.h" diff --git a/indra/llcommon/llrefcount.cpp b/indra/llcommon/llrefcount.cpp index e1876599f..d92735aac 100644 --- a/indra/llcommon/llrefcount.cpp +++ b/indra/llcommon/llrefcount.cpp @@ -38,14 +38,6 @@ LLRefCount::LLRefCount(const LLRefCount& other) : mRef(0) { #if LL_REF_COUNT_DEBUG - if(gAPRPoolp) - { - mMutexp = new LLMutex(gAPRPoolp) ; - } - else - { - mMutexp = NULL ; - } mCrashAtUnlock = FALSE ; #endif } @@ -60,14 +52,6 @@ LLRefCount::LLRefCount() : mRef(0) { #if LL_REF_COUNT_DEBUG - if(gAPRPoolp) - { - mMutexp = new LLMutex(gAPRPoolp) ; - } - else - { - mMutexp = NULL ; - } mCrashAtUnlock = FALSE ; #endif } @@ -78,29 +62,20 @@ LLRefCount::~LLRefCount() { llerrs << "deleting non-zero reference" << llendl; } - -#if LL_REF_COUNT_DEBUG - if(gAPRPoolp) - { - delete mMutexp ; - } -#endif } #if LL_REF_COUNT_DEBUG void LLRefCount::ref() const { - if(mMutexp) - { - if(mMutexp->isLocked()) + if(mMutex.isLocked()) { mCrashAtUnlock = TRUE ; llerrs << "the mutex is locked by the thread: " << mLockedThreadID - << " Current thread: " << LLThread::currentID() << llendl ; + << " Current thread: " << AIThreadID() << llendl ; } - mMutexp->lock() ; - mLockedThreadID = LLThread::currentID() ; + mMutex.lock() ; + mLockedThreadID.reset(); mRef++; @@ -108,27 +83,20 @@ void LLRefCount::ref() const { while(1); //crash here. } - mMutexp->unlock() ; - } - else - { - mRef++; - } + mMutex.unlock() ; } S32 LLRefCount::unref() const { - if(mMutexp) - { - if(mMutexp->isLocked()) + if(mMutex.isLocked()) { mCrashAtUnlock = TRUE ; llerrs << "the mutex is locked by the thread: " << mLockedThreadID - << " Current thread: " << LLThread::currentID() << llendl ; + << " Current thread: " << AIThreadID() << llendl ; } - mMutexp->lock() ; - mLockedThreadID = LLThread::currentID() ; + mMutex.lock() ; + mLockedThreadID.reset(); llassert(mRef >= 1); if (0 == --mRef) @@ -137,7 +105,7 @@ S32 LLRefCount::unref() const { while(1); //crash here. } - mMutexp->unlock() ; + mMutex.unlock() ; delete this; return 0; @@ -147,18 +115,7 @@ S32 LLRefCount::unref() const { while(1); //crash here. } - mMutexp->unlock() ; + mMutex.unlock() ; return mRef; - } - else - { - llassert(mRef >= 1); - if (0 == --mRef) - { - delete this; - return 0; - } - return mRef; - } } #endif diff --git a/indra/llcommon/llrefcount.h b/indra/llcommon/llrefcount.h index 8eb5d53f3..b7831e7fa 100644 --- a/indra/llcommon/llrefcount.h +++ b/indra/llcommon/llrefcount.h @@ -30,7 +30,7 @@ #define LL_REF_COUNT_DEBUG 0 #if LL_REF_COUNT_DEBUG -class LLMutex ; +#include "llthread.h" // LLMutexRootPool #endif //---------------------------------------------------------------------------- @@ -80,8 +80,8 @@ private: mutable S32 mRef; #if LL_REF_COUNT_DEBUG - LLMutex* mMutexp ; - mutable U32 mLockedThreadID ; + mutable LLMutexRootPool mMutex ; + mutable AIThreadID mLockedThreadID ; mutable BOOL mCrashAtUnlock ; #endif }; diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index 47df59d5e..6ce9745cc 100644 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -42,6 +42,7 @@ #include "v4color.h" #include "v4coloru.h" #include "llinstancetracker.h" +#include "llrefcount.h" #include "llcontrolgroupreader.h"