zalsa: return error directly if failed to init, fix mem leak
[jack2.git] / windows / JackWinSemaphore.h
blobe125c5b633101925b388d8e0f768a0a66f0abe88
1 /*
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 #ifndef __JackWinSemaphore__
22 #define __JackWinSemaphore__
24 #include "JackSynchro.h"
25 #ifdef __MINGW32__
26 #include <winsock2.h>
27 #endif
28 #include <windows.h>
29 #include <assert.h>
31 namespace Jack
34 /*!
35 \brief Inter process synchronization using system wide semaphore.
38 class JackWinSemaphore : public detail::JackSynchro
41 private:
43 HANDLE fSemaphore;
45 protected:
47 void BuildName(const char* name, const char* server_name, char* res, int size);
49 public:
51 JackWinSemaphore():JackSynchro(), fSemaphore(NULL)
54 bool Signal();
55 bool SignalAll();
56 bool Wait();
57 bool TimedWait(long usec);
59 bool Allocate(const char* name, const char* server_name, int value);
60 bool Connect(const char* name, const char* server_name);
61 bool ConnectInput(const char* name, const char* server_name);
62 bool ConnectOutput(const char* name, const char* server_name);
63 bool Disconnect();
64 void Destroy();
67 } // end of namespace
69 #endif