Browse Source

Add JackWinCriticalSection class.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4748 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.9.9.5
sletz 13 years ago
parent
commit
217b2cd306
3 changed files with 45 additions and 1 deletions
  1. +18
    -0
      windows/JackWinMutex.cpp
  2. +25
    -0
      windows/JackWinMutex.h
  3. +2
    -1
      windows/JackWinProcessSync.h

+ 18
- 0
windows/JackWinMutex.cpp View File

@@ -88,6 +88,24 @@ namespace Jack
{
return(ReleaseMutex(fMutex) != 0);
}
bool JackWinCriticalSection::Lock()
{
EnterCriticalSection(&fSection);
return true;
}

bool JackWinCriticalSection::Trylock()
{
return (TryEnterCriticalSection(&fSection));
}

bool JackWinCriticalSection::Unlock()
{
LeaveCriticalSection(&fSection);
return true;
}



} // namespace


+ 25
- 0
windows/JackWinMutex.h View File

@@ -89,6 +89,31 @@ class SERVER_EXPORT JackWinMutex

};

class SERVER_EXPORT JackWinCriticalSection
{

protected:

LPCRITICAL_SECTION fSection;

public:

JackWinCriticalSection(const char* name = NULL)
{
InitializeCriticalSection(&fSection);
}

virtual ~JackWinCriticalSection()
{
DeleteCriticalSection(&fSection);
}

bool Lock();
bool Trylock();
bool Unlock();

};


} // namespace



+ 2
- 1
windows/JackWinProcessSync.h View File

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

class JackWinProcessSync : public JackWinMutex
//class JackWinProcessSync : public JackWinMutex
class JackWinProcessSync : public JackWinCriticalSection
{

private:


Loading…
Cancel
Save