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 {
34 {
35 public:
36  enum class Type
37  {
38  Default,
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_
Definition: as_render_target.h:27
Type
Definition: posix_rw_mutex.h:36
Implementation of the Mutex and SharedMutex C++14 concepts via POSIX pthread rwlock.
Definition: posix_rw_mutex.h:33
PosixRWMutex & operator=(PosixRWMutex const &)=delete

Copyright © 2012-2016 Canonical Ltd.
Generated on Wed May 10 10:41:27 UTC 2017