00001 #ifndef __MUTEX_H 00002 #define __MUTEX_H 00003 00004 #include <pthread.h> 00005 00006 class Mutex 00007 { 00008 public: 00009 Mutex() { 00010 pthread_mutex_init(&m_mutex, NULL); 00011 } 00012 00013 ~Mutex() { 00014 pthread_mutex_destroy(&m_mutex); 00015 } 00016 00017 void lock() { 00018 pthread_mutex_lock(&m_mutex); 00019 } 00020 00021 void unlock() { 00022 pthread_mutex_unlock(&m_mutex); 00023 } 00024 00025 pthread_mutex_t* getMutex() { 00026 return &m_mutex; 00027 } 00028 00029 protected: 00030 pthread_mutex_t m_mutex; 00031 }; 00032 00033 #endif 00034