20 #include "JackWinMutex.h"    21 #include "JackError.h"    26     bool JackBaseWinMutex::Lock()
    28         if (fOwner != GetCurrentThreadId()) {
    29             DWORD res = WaitForSingleObject(fMutex, INFINITE);
    30             if (res == WAIT_OBJECT_0) {
    31                 fOwner = GetCurrentThreadId();
    34                 jack_log(
"JackBaseWinMutex::Lock res = %d", res);
    38             jack_error(
"JackBaseWinMutex::Lock mutex already locked by thread = %d", GetCurrentThreadId());
    43     bool JackBaseWinMutex::Trylock()
    45         if (fOwner != GetCurrentThreadId()) {
    46             DWORD res = WaitForSingleObject(fMutex, 0);
    47             if (res == WAIT_OBJECT_0) {
    48                 fOwner = GetCurrentThreadId();
    51                 jack_log(
"JackBaseWinMutex::Trylock res = %d", res);
    55             jack_error(
"JackBaseWinMutex::Trylock mutex already locked by thread = %d", GetCurrentThreadId());
    60     bool JackBaseWinMutex::Unlock()
    62         if (fOwner == GetCurrentThreadId()) {
    64             int res = ReleaseMutex(fMutex);
    68                 jack_log(
"JackBaseWinMutex::Unlock res = %d", res);
    72             jack_error(
"JackBaseWinMutex::Unlock mutex not locked by thread = %d", GetCurrentThreadId());
    77     bool JackWinMutex::Lock()
    79         if (WAIT_OBJECT_0 == WaitForSingleObject(fMutex, INFINITE)) {
    82             jack_log(
"JackWinProcessSync::Lock WaitForSingleObject err = %d", GetLastError());
    87     bool JackWinMutex::Trylock()
    89         if (WAIT_OBJECT_0 == WaitForSingleObject(fMutex, 0)) {
    92             jack_log(
"JackWinProcessSync::Trylock WaitForSingleObject err = %d", GetLastError());
    97     bool JackWinMutex::Unlock()
    99         if (!ReleaseMutex(fMutex)) {
   100             jack_log(
"JackWinProcessSync::Unlock ReleaseMutex err = %d", GetLastError());
   107     bool JackWinCriticalSection::Lock()
   109         EnterCriticalSection(&fSection);
   113     bool JackWinCriticalSection::Trylock()
   115         return (TryEnterCriticalSection(&fSection));
   118     bool JackWinCriticalSection::Unlock()
   120         LeaveCriticalSection(&fSection);
 SERVER_EXPORT void jack_error(const char *fmt,...)
SERVER_EXPORT void jack_log(const char *fmt,...)