cpp-pthread  (v1.7.3)
Simple C++ wrapper to pthread functions.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
read_write_lock.hpp
1 //
2 // read_write_lock.hpp
3 // read_write_lock
4 //
5 // Created by herbert koelman on 18/03/2016.
6 //
7 //
8 
9 #ifndef pthread_read_write_lock_hpp
10 #define pthread_read_write_lock_hpp
11 
12 // must be include as first hearder file of each source code file (see IBM's
13 // recommandation for more info p.285 ยง8.3.1).
14 #include <pthread.h>
15 
16 #include "pthread/config.h"
17 #include "pthread/exceptions.hpp"
18 
19 
20 namespace pthread {
21 
36  class read_lock {
37  public:
38 
44  void lock ();
45 
51  void try_lock ();
52 
56  void unlock ();
57 
58 
62  virtual ~read_lock ();
63 
64  protected:
65 
74  read_lock ();
75 
77  pthread_rwlock_t _rwlock;
78  };
79 
85  class write_lock: public read_lock {
86  public:
92  void lock ();
93 
99  void try_lock ();
100 
109  write_lock ();
110 
114  virtual ~write_lock ();
115 
116  };
117 
140 
142 } // namespace pthread
143 
144 #endif /* pthread_read_write_lock_H */
write_lock read_write_lock
pthread_rwlock_t _rwlock