summaryrefslogtreecommitdiff
path: root/src/threadengines/threadengine_pthread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/threadengines/threadengine_pthread.cpp')
-rw-r--r--src/threadengines/threadengine_pthread.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/threadengines/threadengine_pthread.cpp b/src/threadengines/threadengine_pthread.cpp
index 65d1533f3..acdccfeb5 100644
--- a/src/threadengines/threadengine_pthread.cpp
+++ b/src/threadengines/threadengine_pthread.cpp
@@ -79,6 +79,15 @@ void Mutex::Unlock()
pthread_mutex_unlock(&mutex);
}
+/** Attempt to lock the mutex, will return true on success and false on fail
+ * Does not block
+ * @return true or false
+ */
+bool Mutex::TryLock()
+{
+ return pthread_mutex_trylock(&mutex) == 0;
+}
+
/** Constructor
*/
Condition::Condition() : Mutex()