Mutex.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00020 #ifndef COIL_MUTEX_H
00021 #define COIL_MUTEX_H
00022 
00023 #include <pthread.h>
00024 
00025 namespace coil
00026 {
00040   class Mutex
00041   {
00042   public:
00062     Mutex(const char * const name = 0)
00063     {
00064       ::pthread_mutex_init(&mutex_, 0);
00065     }
00066 
00082     ~Mutex()
00083     {
00084       ::pthread_mutex_destroy(&mutex_);
00085     }
00086 
00102     inline void lock()
00103     {
00104       ::pthread_mutex_lock(&mutex_);
00105     }
00106 
00122     inline bool trylock()
00123     {
00124       return ::pthread_mutex_trylock(&mutex_);
00125     }
00126 
00142     inline void unlock()
00143     {
00144       ::pthread_mutex_unlock(&mutex_);
00145     }
00146 
00158     pthread_mutex_t mutex_;
00159 
00160   private:
00161     Mutex(const Mutex&);
00162     Mutex& operator=(const Mutex &);
00163   };
00164 };
00165 #endif // COIL_MUTEX_H


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Aug 27 2015 14:16:38