Jack2
1.9.9
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
common
JackMutex.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 __JackMutex__
23
#define __JackMutex__
24
25
#include <assert.h>
26
#include "JackError.h"
27
#include "JackPlatformPlug.h"
28
29
30
namespace
Jack
31
{
36
class
JackLockAble
37
{
38
39
protected
:
40
41
JackMutex
fMutex;
42
43
JackLockAble
(
const
char
* name = NULL)
44
:fMutex(name)
45
{}
46
~
JackLockAble
()
47
{}
48
49
public
:
50
51
bool
Lock()
52
{
53
return
fMutex.Lock();
54
}
55
56
bool
Trylock()
57
{
58
return
fMutex.Trylock();
59
}
60
61
bool
Unlock()
62
{
63
return
fMutex.Unlock();
64
}
65
66
};
67
68
class
JackLock
69
{
70
private
:
71
72
JackLockAble
* fObj;
73
74
public
:
75
76
JackLock
(
JackLockAble
* obj): fObj(obj)
77
{
78
fObj->Lock();
79
}
80
81
JackLock
(
const
JackLockAble
* obj): fObj((
JackLockAble
*)obj)
82
{
83
fObj->Lock();
84
}
85
86
~
JackLock
()
87
{
88
fObj->Unlock();
89
}
90
};
91
92
93
}
// namespace
94
95
#endif
Jack::JackLockAble
Base class for "lockable" objects.
Definition:
JackMutex.h:36
Jack::JackLock
Definition:
JackMutex.h:68
Jack::JackPosixMutex
Definition:
JackPosixMutex.h:57
Generated by
1.8.5