JackWinProcessSync.h

00001 /*
00002 Copyright (C) 2004-2006 Grame  
00003 
00004 This program is free software; you can redistribute it and/or modify
00005   it under the terms of the GNU General Public License as published by
00006   the Free Software Foundation; either version 2 of the License, or
00007   (at your option) any later version.
00008 
00009   This program is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012   GNU General Public License for more details.
00013 
00014   You should have received a copy of the GNU General Public License
00015   along with this program; if not, write to the Free Software
00016   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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 } // end of namespace
00090 
00091 #endif
00092 

Generated on Thu Feb 14 11:16:02 2008 for Jackdmp by  doxygen 1.5.1