it_bus_pdk/fair_rw_lock.h

00001 #ifndef _IT_BUS_PDK_FAIR_RW_LOCK_H_
00002 #define _IT_BUS_PDK_FAIR_RW_LOCK_H_
00003 
00004 // @Copyright (c) 2003 IONA Technologies PLC. All Rights Reserved.
00005 //
00006 
00007 #include <it_ts/mutex.h>
00008 #include <it_ts/gateway.h>
00009 #include <it_bus/api_defines.h>
00010 
00011 namespace IT_Bus
00012 {
00013     class IT_AFC_API FairRWLock
00014     {
00015       public:
00016 
00017         FairRWLock();
00018 
00019         void lock_write();
00020 
00021         void cancel_write();
00022 
00023         void lock_read();
00024 
00025         void cancel_read();
00026 
00027       protected:
00028 
00029         size_t m_readers;
00030 
00031         IT_Gateway m_write_gateway;
00032 
00033         IT_Mutex m_read_lock;
00034 
00035         IT_Mutex m_lock;
00036     };
00037 
00038 
00039 
00040     class IT_AFC_API ReadLocker
00041     {
00042       public:
00043 
00044         ReadLocker(FairRWLock & lock);
00045         ~ReadLocker();
00046 
00047         void lock();
00048         void cancel();
00049 
00050       private:
00051 
00052         FairRWLock & m_lock;
00053         bool m_has_lock;
00054     };
00055 
00056 
00057     class IT_AFC_API WriteLocker
00058     {
00059       public:
00060 
00061         WriteLocker(FairRWLock & lock);
00062         ~WriteLocker();
00063 
00064         void lock();
00065         void cancel();
00066 
00067       private:
00068 
00069         FairRWLock & m_lock;
00070         bool m_has_lock;
00071     };
00072 }
00073 
00074 #endif  

Generated on Thu Sep 7 11:39:33 2006 for Artix by  doxygen 1.4.7