diff --git a/common/JackMutex.h b/common/JackMutex.h index 5b6bc562..3b9a4fd9 100644 --- a/common/JackMutex.h +++ b/common/JackMutex.h @@ -64,6 +64,11 @@ class JackMutex DWORD dwWaitResult = WaitForSingleObject(fMutex, INFINITE); } + bool Trylock() + { + return (WAIT_OBJECT_0 == WaitForSingleObject(fMutex, 0)); + } + void Unlock() { ReleaseMutex(fMutex); @@ -89,6 +94,11 @@ class JackMutex pthread_mutex_lock(&fMutex); } + bool Trylock() + { + return (pthread_mutex_trylock(&fMutex) == 0); + } + void Unlock() { pthread_mutex_unlock(&fMutex); @@ -116,7 +126,12 @@ class JackLockAble fMutex.Lock(); } - void Unlock() + bool Trylock() + { + return fMutex.Trylock(); + } + + void Unlock() { fMutex.Unlock(); }