SharedLock.h

00001 // $Id: SharedLock.h 21 2010-09-05 04:18:17Z cschwarz1 $
00002 
00003 #ifndef BASE_SHAREDLOCK_H
00004 #define BASE_SHAREDLOCK_H
00005 
00006 #include "Condition.h"
00007 
00008 namespace base {
00010 
00014     class PPBASE_EXPORT SharedLock: public Mutex {
00015     public:
00017         enum {
00018             UNLOCKED = 0,   
00019             READ,           
00020             WRITE,          
00021             DYNAMIC         
00022         };
00023 
00025 
00028         SharedLock(size_t priority = DYNAMIC);
00029 
00031         ~SharedLock();
00032 
00034 
00037         void lock(size_t mode = READ);
00038 
00040         void unlock();
00041 
00042     protected:
00043         size_t     _priority;         
00044         Condition *_rcond;            
00045         size_t     _reader;           
00046         size_t     _reader_waiting;   
00047         size_t     _state;            
00048         Condition *_wcond;            
00049         size_t     _writer_waiting;   
00050     };
00051 }
00052 
00053 #endif