Browse Source

Add Trylock method

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2116 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.71
sletz 17 years ago
parent
commit
e16006d728
1 changed files with 16 additions and 1 deletions
  1. +16
    -1
      common/JackMutex.h

+ 16
- 1
common/JackMutex.h View File

@@ -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();
}


Loading…
Cancel
Save