summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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