diff options
author | AndreyL ProductEngine <alihatskiy@productengine.com> | 2019-05-08 21:41:11 +0300 |
---|---|---|
committer | AndreyL ProductEngine <alihatskiy@productengine.com> | 2019-05-08 21:41:11 +0300 |
commit | 93f0023efad59c6f86ee8003e3a22f1102ad28e8 (patch) | |
tree | ffb06811136a43a737aacfa844974e206f9f5537 /indra/llcommon/llapr.cpp | |
parent | 922793e4898ec272576f32b79cc31b1c299e1e21 (diff) | |
parent | 34322f8f37380df868703051230f2a4109602b3f (diff) |
Merged in lindenlab/viewer-release
Diffstat (limited to 'indra/llcommon/llapr.cpp')
-rw-r--r-- | indra/llcommon/llapr.cpp | 79 |
1 files changed, 6 insertions, 73 deletions
diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index d353d06de2..29f0c7da9a 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -28,13 +28,12 @@ #include "linden_common.h" #include "llapr.h" +#include "llmutex.h" #include "apr_dso.h" #include "llthreadlocalstorage.h" apr_pool_t *gAPRPoolp = NULL; // Global APR memory pool LLVolatileAPRPool *LLAPRFile::sAPRFilePoolp = NULL ; //global volatile APR memory pool. -apr_thread_mutex_t *gLogMutexp = NULL; -apr_thread_mutex_t *gCallStacksLogMutexp = NULL; const S32 FULL_VOLATILE_APR_POOL = 1024 ; //number of references to LLVolatileAPRPool @@ -48,10 +47,6 @@ void ll_init_apr() if (!gAPRPoolp) { apr_pool_create(&gAPRPoolp, NULL); - - // Initialize the logging mutex - apr_thread_mutex_create(&gLogMutexp, APR_THREAD_MUTEX_UNNESTED, gAPRPoolp); - apr_thread_mutex_create(&gCallStacksLogMutexp, APR_THREAD_MUTEX_UNNESTED, gAPRPoolp); } if(!LLAPRFile::sAPRFilePoolp) @@ -75,23 +70,6 @@ void ll_cleanup_apr() LL_INFOS("APR") << "Cleaning up APR" << LL_ENDL; - if (gLogMutexp) - { - // Clean up the logging mutex - - // All other threads NEED to be done before we clean up APR, so this is okay. - apr_thread_mutex_destroy(gLogMutexp); - gLogMutexp = NULL; - } - if (gCallStacksLogMutexp) - { - // Clean up the logging mutex - - // All other threads NEED to be done before we clean up APR, so this is okay. - apr_thread_mutex_destroy(gCallStacksLogMutexp); - gCallStacksLogMutexp = NULL; - } - LLThreadLocalPointerBase::destroyAllThreadLocalStorage(); if (gAPRPoolp) @@ -168,26 +146,19 @@ apr_pool_t* LLAPRPool::getAPRPool() LLVolatileAPRPool::LLVolatileAPRPool(BOOL is_local, apr_pool_t *parent, apr_size_t size, BOOL releasePoolFlag) : LLAPRPool(parent, size, releasePoolFlag), mNumActiveRef(0), - mNumTotalRef(0), - mMutexPool(NULL), - mMutexp(NULL) + mNumTotalRef(0) { //create mutex if(!is_local) //not a local apr_pool, that is: shared by multiple threads. { - apr_pool_create(&mMutexPool, NULL); // Create a pool for mutex - apr_thread_mutex_create(&mMutexp, APR_THREAD_MUTEX_UNNESTED, mMutexPool); + mMutexp.reset(new std::mutex()); } } LLVolatileAPRPool::~LLVolatileAPRPool() { //delete mutex - if(mMutexp) - { - apr_thread_mutex_destroy(mMutexp); - apr_pool_destroy(mMutexPool); - } + mMutexp.reset(); } // @@ -201,7 +172,7 @@ apr_pool_t* LLVolatileAPRPool::getAPRPool() apr_pool_t* LLVolatileAPRPool::getVolatileAPRPool() { - LLScopedLock lock(mMutexp) ; + LLScopedLock lock(mMutexp.get()) ; mNumTotalRef++ ; mNumActiveRef++ ; @@ -216,7 +187,7 @@ apr_pool_t* LLVolatileAPRPool::getVolatileAPRPool() void LLVolatileAPRPool::clearVolatileAPRPool() { - LLScopedLock lock(mMutexp) ; + LLScopedLock lock(mMutexp.get()); if(mNumActiveRef > 0) { @@ -250,44 +221,6 @@ BOOL LLVolatileAPRPool::isFull() { return mNumTotalRef > FULL_VOLATILE_APR_POOL ; } -//--------------------------------------------------------------------- -// -// LLScopedLock -// -LLScopedLock::LLScopedLock(apr_thread_mutex_t* mutex) : mMutex(mutex) -{ - if(mutex) - { - if(ll_apr_warn_status(apr_thread_mutex_lock(mMutex))) - { - mLocked = false; - } - else - { - mLocked = true; - } - } - else - { - mLocked = false; - } -} - -LLScopedLock::~LLScopedLock() -{ - unlock(); -} - -void LLScopedLock::unlock() -{ - if(mLocked) - { - if(!ll_apr_warn_status(apr_thread_mutex_unlock(mMutex))) - { - mLocked = false; - } - } -} //--------------------------------------------------------------------- |