cpp-pthread  (v1.7.3)
Simple C++ wrapper to pthread functions.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
mutex.hpp
1 //
2 // mutex.hpp
3 // cpp-pthread
4 //
5 // Created by herbert koelman on 18/03/2016.
6 //
7 //
8 
9 #ifndef pthread_mutex_hpp
10 #define pthread_mutex_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 <exception>
17 #include <string>
18 
19 #include "pthread/config.h"
20 
21 #include "pthread/exceptions.hpp"
22 
23 
24 namespace pthread {
25 
30  class condition_variable;
31 
37  class mutex {
38 
39  friend class condition_variable;
40 
41  public:
47  void lock ();
48 
57  void try_lock ();
58 
63  void unlock ();
64 
65  /*
66  Constructor/Desctructor
67  @throw mutex_exception if error conditions preventing this method to succeed.
68  */
69  mutex ();
70  virtual ~mutex ();
71 
72  protected:
74  pthread_mutex_t _mutex;
75  };
76 
79 } // namespace pthread
80 
81 
82 #endif /* mutex_hpp */
void unlock()
Definition: mutex.cpp:40
pthread_mutex_t _mutex
Definition: mutex.hpp:74
void lock()
Definition: mutex.cpp:24
void try_lock()
Definition: mutex.cpp:32