Try to lock the mutex. The method will try to lock the mutex. If it fails, the function will return immediately (non-blocking). @return @c true if the lock was acquired, or @c false if the lock could not be acquired.
| 204 | /// @return @c true if the lock was acquired, or @c false if the lock could |
| 205 | /// not be acquired. |
| 206 | inline bool try_lock() |
| 207 | { |
| 208 | #if defined(_TTHREAD_WIN32_) |
| 209 | bool ret = (TryEnterCriticalSection(&mHandle) ? true : false); |
| 210 | if(ret && mAlreadyLocked) |
| 211 | { |
| 212 | LeaveCriticalSection(&mHandle); |
| 213 | ret = false; |
| 214 | } |
| 215 | return ret; |
| 216 | #else |
| 217 | return (pthread_mutex_trylock(&mHandle) == 0) ? true : false; |
| 218 | #endif |
| 219 | } |
| 220 | |
| 221 | /// Unlock the mutex. |
| 222 | /// If any threads are waiting for the lock on this mutex, one of them will |
nothing calls this directly
no outgoing calls
no test coverage detected