_rwlock.h

Go to the documentation of this file.
00001 
00025 /* === S T A R T =========================================================== */
00026 
00027 #ifndef __ETL__RWLOCK_H_
00028 #define __ETL__RWLOCK_H_
00029 
00030 /* === H E A D E R S ======================================================= */
00031 
00032 /* === M A C R O S ========================================================= */
00033 
00034 /* === C L A S S E S & S T R U C T S ======================================= */
00035 
00036 _ETL_BEGIN_NAMESPACE
00037 
00038 class read_write_lock : private Mutex
00039 {
00040 public:
00041 
00042     read_write_lock()
00043     {  }
00044 
00045     ~read_write_lock()
00046     {  }
00047 
00049     class read_lock
00050     {
00051         read_write_lock *_mtx;
00052     public:
00053         read_lock(read_write_lock &x):_mtx(&x) { _mtx->lock_read(); }
00054         ~read_lock() { _mtx->unlock_read(); }
00055         read_write_lock &get() { return *_mtx; }
00056     };
00057 
00059     class write_lock
00060     {
00061         read_write_lock *_mtx;
00062     public:
00063         write_lock(read_write_lock &x):_mtx(&x) { _mtx->lock_write(); }
00064         ~read_lock() { _mtx->unlock_write(); }
00065         read_write_lock &get() { return *_mtx; }
00066     };
00067 
00068     void lock_read(void)
00069     { lock_mutex(); }
00070 
00071     void lock_write(void)
00072     { lock_mutex(); }
00073 
00074     bool try_lock_read(void)
00075     { return try_lock_mutex(); }
00076 
00077     bool try_lock_write(void)
00078     { return try_lock_mutex(); }
00079 
00080     void unlock_write(void)
00081     { unlock_mutex(); }
00082 
00083     void unlock_read(void)
00084     { unlock_mutex(); }
00085 };
00086 
00087 _ETL_END_NAMESPACE
00088 
00089 /* === E X T E R N S ======================================================= */
00090 
00091 /* === E N D =============================================================== */
00092 
00093 #endif

Generated on Tue Jun 20 08:36:47 2006 for ETL by  doxygen 1.4.6