00001 #ifndef MT_SCOPED_READ_LOCK_H 00002 #define MT_SCOPED_READ_LOCK_H 00003 00004 #include "rw_lock.h" 00005 00006 namespace mt 00007 { 00008 00009 class scoped_read_lock 00010 { 00011 MT_PREVENT_COPY(scoped_read_lock) 00012 00013 public: 00014 00015 typedef scoped_read_lock this_type; 00016 typedef void base_type; 00017 00018 scoped_read_lock(rw_lock & rwl) : rw(rwl) 00019 { 00020 this->rw.lock_read(); 00021 } 00022 00023 ~scoped_read_lock(void) 00024 { 00025 this->rw.unlock_read(); 00026 } 00027 00028 protected: 00029 00030 rw_lock & rw; 00031 }; 00032 00033 } 00034 00035 #endif // MT_SCOPED_READ_LOCK_H