scoped_lock.h

Go to the documentation of this file.
00001 
00005 #ifndef SHM_LOCK_H
00006 #define SHM_LOCK_H 1
00007 
00008 #include <pthread.h>
00009 
00015 class scoped_lock
00016 {
00017  public:
00018 
00024   scoped_lock(pthread_mutex_t* m ) {
00025     mutex = m;
00026     pthread_mutex_lock( mutex );
00027   }
00028 
00031   ~scoped_lock() {
00032     pthread_mutex_unlock( mutex );
00033   }
00034 
00039   void wait( pthread_cond_t* cond ) {
00040     int rc = 0;
00041     //    pthread_mutex_lock( mutex );
00042     rc = pthread_cond_wait( cond, mutex );
00043     //    pthread_mutex_unlock( mutex );
00044   }
00045  
00046  private:
00047   pthread_mutex_t* mutex;
00048   
00049   scoped_lock(const scoped_lock& copy);
00050   scoped_lock& operator=(const scoped_lock& rhs);
00051 };
00052  
00053 #endif
00054 

Project shmq hosted by   SourceForge.net
Documentation generated on Sat Sep 2 10:07:40 2006 for shmq by   doxygen.org 1.4.6