UniSet
2.6.0
Титульная страница
Описания
Группы
Пространства имен
Классы
include
Mutex.h
1
/*
2
* Copyright (c) 2015 Pavel Vainerman.
3
*
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
6
* published by the Free Software Foundation, version 2.1.
7
*
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* Lesser General Lesser Public License for more details.
12
*
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15
*/
16
// --------------------------------------------------------------------------
20
// --------------------------------------------------------------------------
21
#ifndef UniSet_MUTEX_H_
22
#define UniSet_MUTEX_H_
23
// -----------------------------------------------------------------------------------------
24
#include <string>
25
#include <memory>
26
#include <mutex>
27
#include <Poco/RWLock.h>
28
// -----------------------------------------------------------------------------------------
29
namespace
uniset
30
{
31
// rwmutex..
32
class
uniset_rwmutex
33
{
34
public
:
35
uniset_rwmutex
(
const
std::string& name );
36
uniset_rwmutex
();
37
~
uniset_rwmutex
();
38
39
void
lock();
40
void
unlock();
41
42
void
wrlock();
43
void
rlock();
44
45
bool
try_lock();
46
bool
try_rlock();
47
bool
try_wrlock();
48
49
uniset_rwmutex
(
const
uniset_rwmutex
& r ) =
delete
;
50
uniset_rwmutex
& operator=(
const
uniset_rwmutex
& r) =
delete
;
51
52
uniset_rwmutex
(
uniset_rwmutex
&& r ) =
default
;
53
uniset_rwmutex
& operator=(
uniset_rwmutex
&& r) =
default
;
54
55
inline
std::string name()
56
{
57
return
nm;
58
}
59
inline
void
setName(
const
std::string& name )
60
{
61
nm = name;
62
}
63
64
private
:
65
std::string nm;
66
friend
class
uniset_rwmutex_lock;
67
std::unique_ptr<Poco::RWLock> m;
68
};
69
70
std::ostream& operator<<(std::ostream& os,
uniset_rwmutex
& m );
71
// -------------------------------------------------------------------------
72
class
uniset_rwmutex_wrlock
73
{
74
public
:
75
uniset_rwmutex_wrlock
(
uniset_rwmutex
& m );
76
~
uniset_rwmutex_wrlock
();
77
78
private
:
79
uniset_rwmutex_wrlock
(
const
uniset_rwmutex_wrlock
&) =
delete
;
80
uniset_rwmutex_wrlock
& operator=(
const
uniset_rwmutex_wrlock
&) =
delete
;
81
uniset_rwmutex
& m;
82
};
83
84
class
uniset_rwmutex_rlock
85
{
86
public
:
87
uniset_rwmutex_rlock
(
uniset_rwmutex
& m );
88
~
uniset_rwmutex_rlock
();
89
90
private
:
91
uniset_rwmutex_rlock
(
const
uniset_rwmutex_rlock
&) =
delete
;
92
uniset_rwmutex_rlock
& operator=(
const
uniset_rwmutex_rlock
&) =
delete
;
93
uniset_rwmutex
& m;
94
};
95
// -------------------------------------------------------------------------
96
}
// end of UniSetTypes namespace
97
98
#endif
uniset
Definition:
CallbackTimer.h:29
uniset::uniset_rwmutex_wrlock
Definition:
Mutex.h:72
uniset::uniset_rwmutex
Definition:
Mutex.h:32
uniset::uniset_rwmutex_rlock
Definition:
Mutex.h:84
Документация по UniSet. Последние изменения: Пн 16 Янв 2017 18:22:33. Создано системой
1.8.8