(file) Return to ReadWriteSem.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/ReadWriteSem.h between version 1.6.6.2 and 1.14

version 1.6.6.2, 2008/09/29 17:41:56 version 1.14, 2008/09/16 18:37:03
Line 40 
Line 40 
 #include <Pegasus/Common/Mutex.h> #include <Pegasus/Common/Mutex.h>
 #include <Pegasus/Common/AtomicInt.h> #include <Pegasus/Common/AtomicInt.h>
  
 #define PEG_SEM_READ 1  
 #define PEG_SEM_WRITE 2  
   
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 /** /**
Line 70 
Line 67 
 struct ReadWriteSemRep struct ReadWriteSemRep
 { {
     pthread_rwlock_t rwlock;     pthread_rwlock_t rwlock;
     ThreadType owner;  
 }; };
 #endif /* PEGASUS_USE_POSIX_RWLOCK */ #endif /* PEGASUS_USE_POSIX_RWLOCK */
  
Line 80 
Line 76 
     Semaphore _rlock;     Semaphore _rlock;
     Mutex _wlock;     Mutex _wlock;
     Mutex _internal_lock;     Mutex _internal_lock;
     ThreadType _owner;      AtomicInt _readers;
       AtomicInt _writers;
     ReadWriteSemRep() :     ReadWriteSemRep() :
         _rlock(10), _wlock(), _internal_lock(), _owner(Threads::self())          _rlock(10), _wlock(), _internal_lock(), _readers(0), _writers(0)
     {     {
     }     }
 }; };
Line 102 
Line 99 
  
     ~ReadWriteSem();     ~ReadWriteSem();
  
     // @exception Deadlock      void waitRead();
     // @exception Permission  
     // @exception WaitFailed  
     inline void wait_read(ThreadType caller)  
     {  
         wait(PEG_SEM_READ, caller );  
     }  
  
     // @exception Deadlock      void waitWrite();
     // @exception Permission  
     // @exception WaitFailed  
     inline void wait_write(ThreadType caller)  
     {  
         wait(PEG_SEM_WRITE, caller);  
     }  
  
     // @exception Permission      void unlockRead();
     inline void unlock_read(ThreadType caller)  
     {  
         unlock(PEG_SEM_READ, caller);  
     }  
  
     // @exception Permission      void unlockWrite();
     inline void unlock_write(ThreadType caller)  
     {  
         unlock(PEG_SEM_WRITE, caller);  
     }  
   
     int read_count() const;  
     int write_count() const;  
   
     // @exception Deadlock  
     // @exception Permission  
     // @exception WaitFailed  
     // @exception TooManyReaders  
     void wait(Uint32 mode, ThreadType caller);  
   
     // @exception Permission  
     void unlock(Uint32 mode, ThreadType caller);  
  
 private: private:
     AtomicInt _readers;  
     AtomicInt _writers;  
     ReadWriteSemRep _rwlock;     ReadWriteSemRep _rwlock;
     friend void extricate_read_write(void *);  
 }; };
  
 //============================================================================== //==============================================================================
Line 161 
Line 124 
  
     ReadLock(ReadWriteSem& rwsem) : _rwsem(rwsem)     ReadLock(ReadWriteSem& rwsem) : _rwsem(rwsem)
     {     {
         _rwsem.wait_read(Threads::self());          _rwsem.waitRead();
     }     }
  
     ~ReadLock()     ~ReadLock()
     {     {
         _rwsem.unlock_read(Threads::self());          _rwsem.unlockRead();
     }     }
  
 private: private:
Line 185 
Line 148 
  
     WriteLock(ReadWriteSem& rwsem) : _rwsem(rwsem)     WriteLock(ReadWriteSem& rwsem) : _rwsem(rwsem)
     {     {
         _rwsem.wait_write(Threads::self());          _rwsem.waitWrite();
     }     }
  
     ~WriteLock()     ~WriteLock()
     {     {
         _rwsem.unlock_write(Threads::self());          _rwsem.unlockWrite();
     }     }
  
 private: private:


Legend:
Removed from v.1.6.6.2  
changed lines
  Added in v.1.14

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2