00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- 00002 //---------------------------------------------------------------------- 00014 //---------------------------------------------------------------------- 00015 #ifndef ICL_CORE_THREAD_RWLOCK_H_INCLUDED 00016 #define ICL_CORE_THREAD_RWLOCK_H_INCLUDED 00017 00018 #include "icl_core/Noncopyable.h" 00019 #include "icl_core/TimeSpan.h" 00020 #include "icl_core/TimeStamp.h" 00021 #include "icl_core_thread/ImportExport.h" 00022 00023 #ifdef _IC_BUILDER_DEPRECATED_STYLE_ 00024 # include "icl_core/Deprecate.h" 00025 #endif 00026 00027 namespace icl_core { 00028 namespace thread { 00029 00030 class RWLockImpl; 00031 00034 class ICL_CORE_THREAD_IMPORT_EXPORT RWLock : protected virtual icl_core::Noncopyable 00035 { 00036 public: 00039 RWLock(); 00040 00043 virtual ~RWLock(); 00044 00049 bool readLock(); 00050 00055 bool readLock(const ::icl_core::TimeStamp& timeout); 00056 00061 bool readLock(const ::icl_core::TimeSpan& timeout); 00062 00069 bool tryReadLock(); 00070 00075 bool writeLock(); 00076 00081 bool writeLock(const ::icl_core::TimeStamp& timeout); 00082 00087 bool writeLock(const ::icl_core::TimeSpan& timeout); 00088 00095 bool tryWriteLock(); 00096 00099 void unlock(); 00100 00102 #ifdef _IC_BUILDER_DEPRECATED_STYLE_ 00103 00107 ICL_CORE_VC_DEPRECATE_STYLE bool ReadLock() ICL_CORE_GCC_DEPRECATE_STYLE; 00108 00113 ICL_CORE_VC_DEPRECATE_STYLE bool ReadLock(const icl_core::TimeStamp& timeout) 00114 ICL_CORE_GCC_DEPRECATE_STYLE; 00115 00120 ICL_CORE_VC_DEPRECATE_STYLE bool ReadLock(const icl_core::TimeSpan& timeout) 00121 ICL_CORE_GCC_DEPRECATE_STYLE; 00122 00126 ICL_CORE_VC_DEPRECATE_STYLE bool TryReadLock() ICL_CORE_GCC_DEPRECATE_STYLE; 00127 00131 ICL_CORE_VC_DEPRECATE_STYLE bool WriteLock() ICL_CORE_GCC_DEPRECATE_STYLE; 00132 00137 ICL_CORE_VC_DEPRECATE_STYLE bool WriteLock(const icl_core::TimeStamp& timeout) 00138 ICL_CORE_GCC_DEPRECATE_STYLE; 00139 00144 ICL_CORE_VC_DEPRECATE_STYLE bool WriteLock(const icl_core::TimeSpan& timeout) 00145 ICL_CORE_GCC_DEPRECATE_STYLE; 00146 00150 ICL_CORE_VC_DEPRECATE_STYLE bool TryWriteLock() ICL_CORE_GCC_DEPRECATE_STYLE; 00151 00155 ICL_CORE_VC_DEPRECATE_STYLE void Unlock() ICL_CORE_GCC_DEPRECATE_STYLE; 00156 00157 #endif 00158 00159 00160 private: 00161 RWLockImpl *m_impl; 00162 }; 00163 00164 } 00165 } 00166 00167 #endif