Mir
include
common
mir
posix_rw_mutex.h
Go to the documentation of this file.
1
/*
2
* Copyright © 2016 Canonical Ltd.
3
*
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License version 3,
6
* as published by the Free Software Foundation.
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General 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
* Authored by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
17
*/
18
19
#ifndef MIR_POSIX_RW_MUTEX_H_
20
#define MIR_POSIX_RW_MUTEX_H_
21
22
#include <pthread.h>
23
24
namespace
mir
25
{
33
class
PosixRWMutex
34
{
35
public
:
36
enum class
Type
37
{
38
Default
,
39
PreferReader
,
40
PreferWriterNonRecursive
41
};
42
43
PosixRWMutex
();
44
PosixRWMutex
(
Type
type);
45
~PosixRWMutex
();
46
47
PosixRWMutex
(
PosixRWMutex
const
&) =
delete
;
48
PosixRWMutex
&
operator=
(
PosixRWMutex
const
&) =
delete
;
49
50
/*
51
* SharedMutex concept implementation
52
*/
53
void
lock_shared
();
54
bool
try_lock_shared
();
55
void
unlock_shared
();
56
57
/*
58
* Mutex concept implementation
59
*/
60
void
lock
();
61
bool
try_lock
();
62
void
unlock
();
63
64
private
:
65
pthread_rwlock_t mutex;
66
};
67
}
68
69
#endif //MIR_POSIX_RW_MUTEX_H_
mir
Definition:
as_render_target.h:27
mir::PosixRWMutex::lock
void lock()
mir::PosixRWMutex::Type::Default
mir::PosixRWMutex::try_lock
bool try_lock()
mir::PosixRWMutex::unlock_shared
void unlock_shared()
mir::PosixRWMutex::PosixRWMutex
PosixRWMutex()
mir::PosixRWMutex::Type
Type
Definition:
posix_rw_mutex.h:36
mir::PosixRWMutex::~PosixRWMutex
~PosixRWMutex()
mir::PosixRWMutex::try_lock_shared
bool try_lock_shared()
mir::PosixRWMutex
Implementation of the Mutex and SharedMutex C++14 concepts via POSIX pthread rwlock.
Definition:
posix_rw_mutex.h:33
mir::PosixRWMutex::Type::PreferWriterNonRecursive
mir::PosixRWMutex::lock_shared
void lock_shared()
mir::PosixRWMutex::unlock
void unlock()
mir::PosixRWMutex::operator=
PosixRWMutex & operator=(PosixRWMutex const &)=delete
mir::PosixRWMutex::Type::PreferReader
Copyright © 2012-2016 Canonical Ltd.
Generated on Mon Jun 5 11:07:25 UTC 2017