Correct install target
[jack2.git] / windows / JackWinProcessSync.h
blobf652e486ea70f0a0225e6c01c2f6aec403377e00
1 /*
2 Copyright (C) 2004-2006 Grame
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 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 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __JackWinProcessSync__
21 #define __JackWinProcessSync__
23 #include "JackSyncInterface.h"
24 #include <windows.h>
25 #include <new>
27 namespace Jack
30 /*!
31 \brief A synchronization primitive built using a condition variable.
34 class JackWinProcessSync : public JackSyncInterface
37 private:
39 HANDLE fEvent;
41 public:
43 JackWinProcessSync()
45 fEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
46 if (fEvent == NULL)
47 throw new std::bad_alloc;
49 virtual ~JackWinProcessSync()
51 CloseHandle(fEvent);
54 bool Allocate(const char* name)
56 return true;
59 bool Connect(const char* name)
61 return true;
64 void Destroy()
67 bool TimedWait(long usec)
69 JackLog("JackWinProcessSync::Wait time out = %ld\n", usec);
70 DWORD res = WaitForSingleObject(fEvent, usec / 1000);
71 JackLog("JackWinProcessSync::Wait finished res = %ld\n", res == WAIT_OBJECT_0);
72 return (res == WAIT_OBJECT_0);
75 void Wait()
77 JackLog("JackWinProcessSync::Wait...\n");
78 WaitForSingleObject(fEvent, INFINITE);
79 JackLog("JackWinProcessSync::Wait finished\n");
82 void SignalAll()
84 SetEvent(fEvent);
89 } // end of namespace
91 #endif