2 Copyright (C) 2004-2008 Grame
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "JackWinProcessSync.h"
22 #include "JackError.h"
27 void JackWinProcessSync::Signal()
32 void JackWinProcessSync::LockedSignal()
34 WaitForSingleObject(fMutex
, INFINITE
);
39 void JackWinProcessSync::SignalAll()
44 void JackWinProcessSync::LockedSignalAll()
46 WaitForSingleObject(fMutex
, INFINITE
);
51 void JackWinProcessSync::Wait()
54 WaitForSingleObject(fEvent
, INFINITE
);
57 void JackWinProcessSync::LockedWait()
59 /* Does it make sense on Windows, use non-locked version for now... */
63 bool JackWinProcessSync::TimedWait(long usec
)
66 DWORD res
= WaitForSingleObject(fEvent
, usec
/ 1000);
67 return (res
== WAIT_OBJECT_0
);
70 bool JackWinProcessSync::LockedTimedWait(long usec
)
72 /* Does it make sense on Windows, use non-locked version for now...*/
73 return TimedWait(usec
);
77 Code from APPLE CAGuard.cpp : does not seem to work as expected...
79 void JackWinProcessSync::Wait()
82 HANDLE handles[] = { fMutex, fEvent };
83 DWORD res = WaitForMultipleObjects(2, handles, true, INFINITE);
84 if ((res != WAIT_OBJECT_0) && (res != WAIT_TIMEOUT))
85 jack_error("Wait error err = %d", GetLastError());
89 void JackWinProcessSync::LockedWait()
91 WaitForSingleObject(fMutex, INFINITE);
93 HANDLE handles[] = { fMutex, fEvent };
94 DWORD res = WaitForMultipleObjects(2, handles, true, INFINITE);
95 if ((res != WAIT_OBJECT_0) && (res != WAIT_TIMEOUT))
96 jack_error("LockedWait error err = %d", GetLastError());
100 bool JackWinProcessSync::TimedWait(long usec)
102 ReleaseMutex(fMutex);
103 HANDLE handles[] = { fMutex, fEvent };
104 DWORD res = WaitForMultipleObjects(2, handles, true, usec / 1000);
105 if ((res != WAIT_OBJECT_0) && (res != WAIT_TIMEOUT))
106 jack_error("Wait error err = %d", GetLastError());
110 bool JackWinProcessSync::LockedTimedWait(long usec)
112 WaitForSingleObject(fMutex, INFINITE);
113 ReleaseMutex(fMutex);
114 HANDLE handles[] = { fMutex, fEvent };
115 DWORD res = WaitForMultipleObjects(2, handles, true, usec / 1000);
116 if ((res != WAIT_OBJECT_0) && (res != WAIT_TIMEOUT))
117 jack_error("LockedTimedWait error err = %d", GetLastError());
119 return (res == WAIT_OBJECT_0);
123 } // end of namespace