summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-01-28 09:25:16 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2016-01-28 09:25:16 +0100
commitfb5c9c6d808dd43e60859bd3988337ee13f13efa (patch)
tree2f7ae4d406ff9c6bdb32166fec296330398592fb
parent2e71762c498d1ace6afb79ec139a2220f89c32dc (diff)
Added debug
-rw-r--r--src/mutex.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/mutex.cc b/src/mutex.cc
index 8a9439d..a932789 100644
--- a/src/mutex.cc
+++ b/src/mutex.cc
@@ -70,14 +70,19 @@ Mutex::~Mutex()
}
}
+//! \return true if the function succeeds in locking the mutex for the thread.
+//! false otherwise.
bool Mutex::try_lock()
{
#ifdef WIN32
DEBUG(mutex, "%s\n", __PRETTY_FUNCTION__);
- DEBUG(mutex, "WAIT_OBJECT_0: %d, WaitForSingleObject: %d\n",
- WAIT_OBJECT_0, WaitForSingleObject(prv->mutex, 0));
- return WaitForSingleObject(prv->mutex, 0) == WAIT_OBJECT_0;
+ DWORD result = WaitForSingleObject(prv->mutex, 0);
+
+ DEBUG(mutex, "WAIT_OBJECT_0: %lu, WAIT_TIMEOUT: %lu, result: %d\n",
+ WAIT_OBJECT_0, WAIT_TIMEOUT, result);
+
+ return result != WAIT_TIMEOUT;
#else
return pthread_mutex_trylock(&prv->mutex) != EBUSY;
#endif