00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- 00002 00003 // -- BEGIN LICENSE BLOCK ---------------------------------------------- 00004 // This file is part of FZIs ic_workspace. 00005 // 00006 // This program is free software licensed under the LGPL 00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3). 00008 // You can find a copy of this license in LICENSE folder in the top 00009 // directory of the source code. 00010 // 00011 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany 00012 // 00013 // -- END LICENSE BLOCK ------------------------------------------------ 00014 00015 //---------------------------------------------------------------------- 00027 //---------------------------------------------------------------------- 00028 #ifndef ICL_CORE_THREAD_RWLOCK_H_INCLUDED 00029 #define ICL_CORE_THREAD_RWLOCK_H_INCLUDED 00030 00031 #include "icl_core/Noncopyable.h" 00032 #include "icl_core/TimeSpan.h" 00033 #include "icl_core/TimeStamp.h" 00034 #include "icl_core_thread/ImportExport.h" 00035 00036 #ifdef _IC_BUILDER_DEPRECATED_STYLE_ 00037 # include "icl_core/Deprecate.h" 00038 #endif 00039 00040 namespace icl_core { 00041 namespace thread { 00042 00043 class RWLockImpl; 00044 00047 class ICL_CORE_THREAD_IMPORT_EXPORT RWLock : protected virtual icl_core::Noncopyable 00048 { 00049 public: 00052 RWLock(); 00053 00056 virtual ~RWLock(); 00057 00062 bool readLock(); 00063 00068 bool readLock(const ::icl_core::TimeStamp& timeout); 00069 00074 bool readLock(const ::icl_core::TimeSpan& timeout); 00075 00082 bool tryReadLock(); 00083 00088 bool writeLock(); 00089 00094 bool writeLock(const ::icl_core::TimeStamp& timeout); 00095 00100 bool writeLock(const ::icl_core::TimeSpan& timeout); 00101 00108 bool tryWriteLock(); 00109 00112 void unlock(); 00113 00115 #ifdef _IC_BUILDER_DEPRECATED_STYLE_ 00116 00120 ICL_CORE_VC_DEPRECATE_STYLE bool ReadLock() ICL_CORE_GCC_DEPRECATE_STYLE; 00121 00126 ICL_CORE_VC_DEPRECATE_STYLE bool ReadLock(const icl_core::TimeStamp& timeout) 00127 ICL_CORE_GCC_DEPRECATE_STYLE; 00128 00133 ICL_CORE_VC_DEPRECATE_STYLE bool ReadLock(const icl_core::TimeSpan& timeout) 00134 ICL_CORE_GCC_DEPRECATE_STYLE; 00135 00139 ICL_CORE_VC_DEPRECATE_STYLE bool TryReadLock() ICL_CORE_GCC_DEPRECATE_STYLE; 00140 00144 ICL_CORE_VC_DEPRECATE_STYLE bool WriteLock() ICL_CORE_GCC_DEPRECATE_STYLE; 00145 00150 ICL_CORE_VC_DEPRECATE_STYLE bool WriteLock(const icl_core::TimeStamp& timeout) 00151 ICL_CORE_GCC_DEPRECATE_STYLE; 00152 00157 ICL_CORE_VC_DEPRECATE_STYLE bool WriteLock(const icl_core::TimeSpan& timeout) 00158 ICL_CORE_GCC_DEPRECATE_STYLE; 00159 00163 ICL_CORE_VC_DEPRECATE_STYLE bool TryWriteLock() ICL_CORE_GCC_DEPRECATE_STYLE; 00164 00168 ICL_CORE_VC_DEPRECATE_STYLE void Unlock() ICL_CORE_GCC_DEPRECATE_STYLE; 00169 00170 #endif 00171 00172 00173 private: 00174 RWLockImpl *m_impl; 00175 }; 00176 00177 } 00178 } 00179 00180 #endif