UniSet
2.32.1
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 <Poco/RWLock.h>
27
// -----------------------------------------------------------------------------------------
28
namespace
uniset
29
{
30
// rwmutex..
31
class
uniset_rwmutex
32
{
33
public
:
34
uniset_rwmutex
(
const
std::string& name );
35
uniset_rwmutex
();
36
~uniset_rwmutex
();
37
38
void
lock();
39
void
unlock();
40
41
void
wrlock();
42
void
rlock();
43
44
bool
try_lock();
45
bool
try_rlock();
46
bool
try_wrlock();
47
48
uniset_rwmutex
(
const
uniset_rwmutex
& r ) =
delete
;
49
uniset_rwmutex
& operator=(
const
uniset_rwmutex
& r) =
delete
;
50
51
uniset_rwmutex
(
uniset_rwmutex
&& r ) =
default
;
52
uniset_rwmutex
& operator=(
uniset_rwmutex
&& r) =
default
;
53
54
inline
std::string name()
const
55
{
56
return
nm;
57
}
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::uniset_rwmutex_rlock
Definition
Mutex.h:85
uniset::uniset_rwmutex_wrlock
Definition
Mutex.h:73
uniset::uniset_rwmutex
Definition
Mutex.h:32
uniset
Definition
Calibration.h:27
Документация по UniSet. Последние изменения: Ср 19 Июл 2023 21:17:14. Создано системой
1.10.0