00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- 00002 //---------------------------------------------------------------------- 00015 //---------------------------------------------------------------------- 00016 #ifndef ICL_CORE_THREAD_SCOPED_MUTEX_LOCK_H_INCLUDED 00017 #define ICL_CORE_THREAD_SCOPED_MUTEX_LOCK_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 Mutex; 00031 00037 class ICL_CORE_THREAD_IMPORT_EXPORT ScopedMutexLock : protected virtual icl_core::Noncopyable 00038 { 00039 public: 00044 explicit ScopedMutexLock(Mutex& mutex, bool force = true); 00047 ~ScopedMutexLock(); 00048 00051 bool isLocked() const { return m_is_locked; } 00052 00055 operator bool () const { return isLocked(); } 00056 00058 #ifdef _IC_BUILDER_DEPRECATED_STYLE_ 00059 00063 ICL_CORE_VC_DEPRECATE_STYLE bool IsLocked() const ICL_CORE_GCC_DEPRECATE_STYLE; 00064 00065 #endif 00066 00067 00068 private: 00069 Mutex& m_mutex; 00070 bool m_is_locked; 00071 }; 00072 00073 } 00074 } 00075 00076 #endif