00001 #ifndef __GUARD_H 00002 #define __GUARD_H 00003 00004 extern "C" { 00005 #include <pthread.h> 00006 } 00007 00022 class Guard 00023 { 00024 public: 00025 Guard(const pthread_mutex_t *mutex); 00026 ~Guard(); 00027 00028 // Utility methods to help in creating and destroying a mutex that 00029 // can then be used with a Guard. 00030 static void initialize_mutex(pthread_mutex_t &mutex); 00031 static void destroy_mutex(pthread_mutex_t &mutex); 00032 00033 protected: 00035 const pthread_mutex_t *mutex; 00036 }; 00037 00038 #endif /* __GUARD_H */