Protium
Math and Design Features
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
Mutex.h
Go to the documentation of this file.
1 
6 #ifndef Protium_Threads_h_
7 #define Protium_Threads_h_
8 
9 #include "Protium/Design/Assert.h" //For compile-time assertions
10 
11 #include <pthread.h> //For access to pthreads
12 #include <cassert> //For static-assertions
13 
14 namespace Protium{
15  namespace Threads{
16 
22  class Mutex{
23  Mutex(const Mutex&);
24  Mutex & operator=(const Mutex& );
25  pthread_mutex_t fMtx;
26  bool fIsLocked;
27  public:
28  Mutex();
30  void Lock();
32  void Unlock();
36  bool IsLocked();
37  };
38  }
39 }
40 
41 
42 
43 #endif //Protium_Threads_h_
pthread_mutex_t fMtx
Definition: Mutex.h:25
Wrapper class for pthreads-style mutexes.
Definition: Mutex.h:22
Mutex & operator=(const Mutex &)
void Lock()
Attempts to lock the mutex and blocks until mutex is available.
Definition: Mutex.cxx:7
void Unlock()
Unlocks the mutex for the next usage.
Definition: Mutex.cxx:12