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::sys::ScopedLock
Scoped lock template: calls lock() in ctor, unlock() in dtor.
Definition:
Mutex.h:30
qpid::sys::ConditionalScopedLock::~ConditionalScopedLock
~ConditionalScopedLock()
Definition:
Mutex.h:74
qpid::sys::ScopedUnlock
Definition:
Mutex.h:40
qpid::sys::ScopedLock::~ScopedLock
~ScopedLock()
Definition:
Mutex.h:34
Mutex.h
qpid::sys::ScopedUnlock::ScopedUnlock
ScopedUnlock(L &l)
Definition:
Mutex.h:43
qpid::sys::ConditionalScopedLock::lockAcquired
bool lockAcquired()
Definition:
Mutex.h:75
qpid::sys::ScopedRlock
Definition:
Mutex.h:50
qpid::sys::ScopedWlock
Definition:
Mutex.h:60
qpid::sys::ScopedWlock::ScopedWlock
ScopedWlock(L &l)
Definition:
Mutex.h:63
qpid::sys::ConditionalScopedLock
Definition:
Mutex.h:70
Mutex.h
qpid::sys::ScopedRlock::ScopedRlock
ScopedRlock(L &l)
Definition:
Mutex.h:53
qpid::sys::ScopedWlock::~ScopedWlock
~ScopedWlock()
Definition:
Mutex.h:64
qpid::sys::ScopedLock::ScopedLock
ScopedLock(L &l)
Definition:
Mutex.h:33
qpid::sys::ScopedRlock::~ScopedRlock
~ScopedRlock()
Definition:
Mutex.h:54
qpid::sys::ScopedUnlock::~ScopedUnlock
~ScopedUnlock()
Definition:
Mutex.h:44
qpid::sys::ConditionalScopedLock::ConditionalScopedLock
ConditionalScopedLock(L &l)
Definition:
Mutex.h:73
Qpid C++ API Reference
Generated on Thu Mar 31 2016 for Qpid C++ Client API by
1.8.5