From fb5c9c6d808dd43e60859bd3988337ee13f13efa Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 28 Jan 2016 09:25:16 +0100 Subject: Added debug --- src/mutex.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') 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 -- cgit v1.2.3