diff options
| author | Callum Prentice <callum@lindenlab.com> | 2014-02-27 16:27:58 -0800 |
|---|---|---|
| committer | Callum Prentice <callum@lindenlab.com> | 2014-02-27 16:27:58 -0800 |
| commit | 6e21b127d4224716f485e3fc8a195676f5708721 (patch) | |
| tree | 220d9738307a1c81fcd7eff2f68d675db43cb8f0 /indra/llcommon/llthread.cpp | |
| parent | d3abd1ca85028ba143dd715e91b145bf936875f1 (diff) | |
| parent | de8fea13627cc5978b8a6135802a52864a11c39a (diff) | |
merge with head
Diffstat (limited to 'indra/llcommon/llthread.cpp')
| -rwxr-xr-x | indra/llcommon/llthread.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 60adeeaeb7..e67d1bc57b 100755 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -3,7 +3,7 @@ * * $LicenseInfo:firstyear=2004&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2010-2013, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -373,6 +373,36 @@ void LLMutex::lock() #endif } +bool LLMutex::trylock() +{ + if(isSelfLocked()) + { //redundant lock + mCount++; + return true; + } + + apr_status_t status(apr_thread_mutex_trylock(mAPRMutexp)); + if (APR_STATUS_IS_EBUSY(status)) + { + return false; + } + +#if MUTEX_DEBUG + // Have to have the lock before we can access the debug info + U32 id = LLThread::currentID(); + if (mIsLocked[id] != FALSE) + llerrs << "Already locked in Thread: " << id << llendl; + mIsLocked[id] = TRUE; +#endif + +#if LL_DARWIN + mLockingThread = LLThread::currentID(); +#else + mLockingThread = sThreadID; +#endif + return true; +} + void LLMutex::unlock() { if (mCount > 0) |
