Commit a38847e6 authored by sletz's avatar sletz
Browse files

Try alternative synch primitive on Windows.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4740 0c269be4-1314-0410-8aa9-9f06e86f4224
parent c58666dd
......@@ -17,7 +17,6 @@
*/
#include "JackWinProcessSync.h"
#include "JackError.h"
......@@ -47,7 +46,8 @@ void JackWinProcessSync::LockedSignalAll()
SetEvent(fEvent);
ReleaseMutex(fMutex);
}
/*
void JackWinProcessSync::Wait()
{
ReleaseMutex(fMutex);
......@@ -56,7 +56,7 @@ void JackWinProcessSync::Wait()
void JackWinProcessSync::LockedWait()
{
/* Does it make sense on Windows, use non-locked version for now... */
// Does it make sense on Windows, use non-locked version for now...
Wait();
}
......@@ -69,32 +69,28 @@ bool JackWinProcessSync::TimedWait(long usec)
bool JackWinProcessSync::LockedTimedWait(long usec)
{
/* Does it make sense on Windows, use non-locked version for now...*/
// Does it make sense on Windows, use non-locked version for now...
return TimedWait(usec);
}
*/
/*
Code from APPLE CAGuard.cpp : does not seem to work as expected...
// Code from APPLE CAGuard.cpp : does not seem to work as expected...
void JackWinProcessSync::Wait()
{
ReleaseMutex(fMutex);
HANDLE handles[] = { fMutex, fEvent };
DWORD res = WaitForMultipleObjects(2, handles, true, INFINITE);
if ((res != WAIT_OBJECT_0) && (res != WAIT_TIMEOUT))
if (res != WAIT_OBJECT_0)
jack_error("Wait error err = %d", GetLastError());
ResetEvent(fEvent);
}
void JackWinProcessSync::LockedWait()
{
WaitForSingleObject(fMutex, INFINITE);
ReleaseMutex(fMutex);
HANDLE handles[] = { fMutex, fEvent };
DWORD res = WaitForMultipleObjects(2, handles, true, INFINITE);
if ((res != WAIT_OBJECT_0) && (res != WAIT_TIMEOUT))
jack_error("LockedWait error err = %d", GetLastError());
ResetEvent(fEvent);
// Does it make sense on Windows, use non-locked version for now...
Wait();
}
bool JackWinProcessSync::TimedWait(long usec)
......@@ -103,22 +99,21 @@ bool JackWinProcessSync::TimedWait(long usec)
HANDLE handles[] = { fMutex, fEvent };
DWORD res = WaitForMultipleObjects(2, handles, true, usec / 1000);
if ((res != WAIT_OBJECT_0) && (res != WAIT_TIMEOUT))
jack_error("Wait error err = %d", GetLastError());
ResetEvent(fEvent);
jack_error("TimedWait error err = %d", GetLastError());
ResetEvent(fEvent);
return (res == WAIT_OBJECT_0);
}
bool JackWinProcessSync::LockedTimedWait(long usec)
{
WaitForSingleObject(fMutex, INFINITE);
ReleaseMutex(fMutex);
HANDLE handles[] = { fMutex, fEvent };
DWORD res = WaitForMultipleObjects(2, handles, true, usec / 1000);
if ((res != WAIT_OBJECT_0) && (res != WAIT_TIMEOUT))
jack_error("LockedTimedWait error err = %d", GetLastError());
ResetEvent(fEvent);
return (res == WAIT_OBJECT_0);
// Does it make sense on Windows, use non-locked version for now...
//return TimedWait(usec);
bool res = TimedWait(usec);
if (!res)
jack_error("LockedTimedWait error usec = %d", usec);
return res;
}
*/
} // end of namespace
......
/*
Copyright (C) 2004-2008 Grame
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
......@@ -41,22 +41,23 @@ class JackWinProcessSync : public JackWinMutex
JackWinProcessSync():JackWinMutex()
{
fEvent = (HANDLE)CreateEvent(NULL, FALSE, FALSE, NULL);
//fEvent = (HANDLE)CreateEvent(NULL, FALSE, FALSE, NULL);
fEvent = (HANDLE)CreateEvent(NULL, TRUE, FALSE, NULL); // Needs ResetEvent
}
~JackWinProcessSync()
{
CloseHandle(fEvent);
}
bool TimedWait(long usec);
bool LockedTimedWait(long usec);
void Wait();
void LockedWait();
void Signal();
void LockedSignal();
void SignalAll();
void LockedSignalAll();
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment