Implement boost and stl mutexes and atomics.
This commit is contained in:
@@ -30,60 +30,6 @@
|
||||
#include "llapr.h"
|
||||
#include "llscopedvolatileaprpool.h"
|
||||
|
||||
LLFastTimer::DeclareTimer FT_WAIT_FOR_SCOPEDLOCK("LLScopedLock");
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// LLScopedLock
|
||||
//
|
||||
LLScopedLock::LLScopedLock(apr_thread_mutex_t* mutex) : mMutex(mutex)
|
||||
{
|
||||
mLocked = !!mutex;
|
||||
if (LL_LIKELY(mutex))
|
||||
{
|
||||
apr_status_t status = apr_thread_mutex_trylock(mMutex);
|
||||
while (LL_UNLIKELY(status != APR_SUCCESS))
|
||||
{
|
||||
if (APR_STATUS_IS_EBUSY(status))
|
||||
{
|
||||
if (AIThreadID::in_main_thread_inline())
|
||||
{
|
||||
LLFastTimer ft1(FT_WAIT_FOR_SCOPEDLOCK);
|
||||
status = apr_thread_mutex_lock(mMutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = apr_thread_mutex_lock(mMutex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ll_apr_warn_status(status);
|
||||
mLocked = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LLScopedLock::~LLScopedLock()
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
|
||||
void LLScopedLock::unlock()
|
||||
{
|
||||
if(mLocked)
|
||||
{
|
||||
if(!ll_apr_warn_status(apr_thread_mutex_unlock(mMutex)))
|
||||
{
|
||||
mLocked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
bool ll_apr_warn_status(apr_status_t status)
|
||||
{
|
||||
if(APR_SUCCESS == status) return false;
|
||||
|
||||
Reference in New Issue
Block a user