Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET
Apache Qpid Documentation
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
qpid
sys
Mutex.h
Go to the documentation of this file.
1
#ifndef _sys_Mutex_h
2
#define _sys_Mutex_h
3
4
/*
5
*
6
* Copyright (c) 2006 The Apache Software Foundation
7
*
8
* Licensed under the Apache License, Version 2.0 (the "License");
9
* you may not use this file except in compliance with the License.
10
* You may obtain a copy of the License at
11
*
12
* http://www.apache.org/licenses/LICENSE-2.0
13
*
14
* Unless required by applicable law or agreed to in writing, software
15
* distributed under the License is distributed on an "AS IS" BASIS,
16
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
* See the License for the specific language governing permissions and
18
* limitations under the License.
19
*
20
*/
21
22
namespace
qpid {
23
namespace
sys {
24
29
template
<
class
L>
30
class
ScopedLock
31
{
32
public
:
33
ScopedLock
(L& l) : mutex(l) { mutex.lock(); }
34
~ScopedLock
() { mutex.unlock(); }
35
private
:
36
L& mutex;
37
};
38
39
template
<
class
L>
40
class
ScopedUnlock
41
{
42
public
:
43
ScopedUnlock
(L& l) : mutex(l) { mutex.unlock(); }
44
~ScopedUnlock
() { mutex.lock(); }
45
private
:
46
L& mutex;
47
};
48
49
template
<
class
L>
50
class
ScopedRlock
51
{
52
public
:
53
ScopedRlock
(L& l) : mutex(l) { mutex.rlock(); }
54
~ScopedRlock
() { mutex.unlock(); }
55
private
:
56
L& mutex;
57
};
58
59
template
<
class
L>
60
class
ScopedWlock
61
{
62
public
:
63
ScopedWlock
(L& l) : mutex(l) { mutex.wlock(); }
64
~ScopedWlock
() { mutex.unlock(); }
65
private
:
66
L& mutex;
67
};
68
69
template
<
class
L>
70
class
ConditionalScopedLock
71
{
72
public
:
73
ConditionalScopedLock
(L& l) : mutex(l) { acquired = mutex.trylock(); }
74
~ConditionalScopedLock
() {
if
(acquired) mutex.unlock(); }
75
bool
lockAcquired
() {
return
acquired; }
76
private
:
77
L& mutex;
78
bool
acquired;
79
};
80
81
}}
82
83
#ifdef USE_APR_PLATFORM
84
#include "apr/Mutex.h"
85
#elif defined (_WIN32)
86
#include "
windows/Mutex.h
"
87
#else
88
#include "
posix/Mutex.h
"
89
#endif
90
91
#endif
Qpid C++ API Reference
Generated on Thu Aug 28 2014 for Qpid C++ Client API by
1.8.3.1