Mutex.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00020 #ifndef COIL_MUTEX_H
00021 #define COIL_MUTEX_H
00022 
00023 #include <coil/config_coil.h>
00024 #if defined (WIN32)
00025 #pragma warning( disable : 4244 ) 
00026 #pragma warning( disable : 4312 ) 
00027 #endif
00028 #include <ace/OS_NS_Thread.h>
00029 #if defined (WIN32)
00030 #pragma warning( default : 4244 ) 
00031 #pragma warning( default : 4312 ) 
00032 #endif
00033 
00034 namespace coil
00035 {
00036   class Mutex
00037   {
00038   public:
00039     Mutex(const char* naem = 0)
00040     {
00041       ACE_OS::thread_mutex_init(&mutex_, 0);
00042     }
00043 
00044     ~Mutex()
00045     {
00046       ACE_OS::thread_mutex_destroy(&mutex_);
00047     }
00048 
00049     inline void lock()
00050     {
00051       ACE_OS::thread_mutex_lock(&mutex_);
00052     }
00053 
00054     inline bool trylock()
00055     {
00056       return ACE_OS::thread_mutex_trylock(&mutex_);
00057     }
00058 
00059     inline void unlock()
00060     {
00061       ACE_OS::thread_mutex_unlock(&mutex_);
00062     }
00063     ACE_thread_mutex_t mutex_;
00064 
00065   private:
00066     Mutex(const Mutex&);
00067     Mutex& operator=(const Mutex &);
00068   };
00069 };
00070 #endif // COIL_MUTEX_H


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