Browse Source

Add new JackBasePosixMutex class.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3665 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/v1.9.4
sletz 16 years ago
parent
commit
eb6d5d1655
2 changed files with 44 additions and 3 deletions
  1. +41
    -0
      posix/JackPosixMutex.h
  2. +3
    -3
      posix/JackProcessSync.h

+ 41
- 0
posix/JackPosixMutex.h View File

@@ -33,6 +33,47 @@ namespace Jack
\brief Mutex abstraction.
*/

class JackBasePosixMutex
{
protected:
pthread_mutex_t fMutex;
public:
JackBasePosixMutex()
{
pthread_mutex_init(&fMutex, NULL);
}
virtual ~JackBasePosixMutex()
{
pthread_mutex_destroy(&fMutex);
}
void Lock()
{
int res = pthread_mutex_lock(&fMutex);
if (res != 0)
jack_error("JackBasePosixMutex::Lock res = %d", res);
}
bool Trylock()
{
return (pthread_mutex_trylock(&fMutex) == 0);
}
void Unlock()
{
int res = pthread_mutex_unlock(&fMutex);
if (res != 0)
jack_error("JackBasePosixMutex::Unlock res = %d", res);
}
};
class JackPosixMutex
{



+ 3
- 3
posix/JackProcessSync.h View File

@@ -32,7 +32,7 @@ namespace Jack
\brief A synchronization primitive built using a condition variable.
*/

class JackProcessSync : public JackPosixMutex
class JackProcessSync : public JackBasePosixMutex
{

private:
@@ -41,12 +41,12 @@ class JackProcessSync : public JackPosixMutex

public:

JackProcessSync():JackPosixMutex()
JackProcessSync():JackBasePosixMutex()
{
pthread_cond_init(&fCond, NULL);
}

~JackProcessSync()
virtual ~JackProcessSync()
{
pthread_cond_destroy(&fCond);
}


Loading…
Cancel
Save