00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __JackWinProcessSync__
00021 #define __JackWinProcessSync__
00022
00023 #include "JackSyncInterface.h"
00024 #include <windows.h>
00025 #include <new>
00026
00027 namespace Jack
00028 {
00029
00034 class JackWinProcessSync : public JackSyncInterface
00035 {
00036
00037 private:
00038
00039 HANDLE fEvent;
00040
00041 public:
00042
00043 JackWinProcessSync()
00044 {
00045 fEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
00046 if (fEvent == NULL)
00047 throw new std::bad_alloc;
00048 }
00049 virtual ~JackWinProcessSync()
00050 {
00051 CloseHandle(fEvent);
00052 }
00053
00054 bool Allocate(const char* name)
00055 {
00056 return true;
00057 }
00058
00059 bool Connect(const char* name)
00060 {
00061 return true;
00062 }
00063
00064 void Destroy()
00065 {}
00066
00067 bool TimedWait(long usec)
00068 {
00069 JackLog("JackWinProcessSync::Wait time out = %ld\n", usec);
00070 DWORD res = WaitForSingleObject(fEvent, usec / 1000);
00071 JackLog("JackWinProcessSync::Wait finished res = %ld\n", res == WAIT_OBJECT_0);
00072 return (res == WAIT_OBJECT_0);
00073 }
00074
00075 void Wait()
00076 {
00077 JackLog("JackWinProcessSync::Wait...\n");
00078 WaitForSingleObject(fEvent, INFINITE);
00079 JackLog("JackWinProcessSync::Wait finished\n");
00080 }
00081
00082 void SignalAll()
00083 {
00084 SetEvent(fEvent);
00085 }
00086
00087 };
00088
00089 }
00090
00091 #endif
00092