00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- 00002 //---------------------------------------------------------------------- 00015 //---------------------------------------------------------------------- 00016 #ifndef ICL_CORE_THREAD_SCOPED_RWLOCK_H_INCLUDED 00017 #define ICL_CORE_THREAD_SCOPED_RWLOCK_H_INCLUDED 00018 00019 #include <icl_core/BaseTypes.h> 00020 #include <icl_core/Noncopyable.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 RWLock; 00031 00037 class ICL_CORE_THREAD_IMPORT_EXPORT ScopedRWLock : protected virtual icl_core::Noncopyable 00038 { 00039 public: 00041 enum LockMode 00042 { 00043 eLM_READ_LOCK, 00044 eLM_WRITE_LOCK 00045 }; 00046 00053 explicit ScopedRWLock(RWLock& lock, LockMode lock_mode, bool force = true); 00054 00057 ~ScopedRWLock(); 00058 00061 bool isLocked() const { return m_is_locked; } 00062 00066 operator bool () const { return isLocked(); } 00067 00069 #ifdef _IC_BUILDER_DEPRECATED_STYLE_ 00070 00074 ICL_CORE_VC_DEPRECATE_STYLE bool IsLocked() const ICL_CORE_GCC_DEPRECATE_STYLE; 00075 00076 #endif 00077 00078 00079 private: 00080 RWLock& m_lock; 00081 bool m_is_locked; 00082 }; 00083 00084 } 00085 } 00086 00087 #endif