Jack2  1.9.9
JackPosixMutex.h
1 /*
2  Copyright (C) 2006 Grame
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library 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 GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18  Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France
19  grame@grame.fr
20 */
21 
22 #ifndef __JackPosixMutex__
23 #define __JackPosixMutex__
24 
25 #include "JackException.h"
26 #include "JackCompilerDeps.h"
27 
28 #include <pthread.h>
29 #include <stdio.h>
30 #include <assert.h>
31 
32 namespace Jack
33 {
38 class SERVER_EXPORT JackBasePosixMutex
39 {
40 
41  protected:
42 
43  pthread_mutex_t fMutex;
44  pthread_t fOwner;
45 
46  public:
47 
48  JackBasePosixMutex(const char* name = NULL);
49  virtual ~JackBasePosixMutex();
50 
51  bool Lock();
52  bool Trylock();
53  bool Unlock();
54 
55 };
56 
57 class SERVER_EXPORT JackPosixMutex
58 {
59  protected:
60 
61  pthread_mutex_t fMutex;
62 
63  public:
64 
65  JackPosixMutex(const char* name = NULL);
66  virtual ~JackPosixMutex();
67 
68  bool Lock();
69  bool Trylock();
70  bool Unlock();
71 };
72 
73 } // namespace
74 
75 #endif
Mutex abstraction.