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_MUTEX_H_INCLUDED 00029 #define ICL_CORE_THREAD_MUTEX_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 MutexImpl; 00044 00047 class ICL_CORE_THREAD_IMPORT_EXPORT Mutex : protected virtual icl_core::Noncopyable 00048 { 00049 public: 00052 Mutex(); 00053 00056 virtual ~Mutex(); 00057 00062 bool lock(); 00063 00068 bool lock(const ::icl_core::TimeStamp& timeout); 00069 00074 bool lock(const ::icl_core::TimeSpan& timeout); 00075 00082 bool tryLock(); 00083 00086 void unlock(); 00087 00089 #ifdef _IC_BUILDER_DEPRECATED_STYLE_ 00090 00095 ICL_CORE_VC_DEPRECATE_STYLE bool Lock() ICL_CORE_GCC_DEPRECATE_STYLE; 00096 00101 ICL_CORE_VC_DEPRECATE_STYLE bool Lock(const icl_core::TimeStamp& timeout) 00102 ICL_CORE_GCC_DEPRECATE_STYLE; 00103 00108 ICL_CORE_VC_DEPRECATE_STYLE bool Lock(const icl_core::TimeSpan& timeout) 00109 ICL_CORE_GCC_DEPRECATE_STYLE; 00110 00117 ICL_CORE_VC_DEPRECATE_STYLE bool TryLock() ICL_CORE_GCC_DEPRECATE_STYLE; 00118 00121 ICL_CORE_VC_DEPRECATE_STYLE void Unlock() ICL_CORE_GCC_DEPRECATE_STYLE; 00122 00123 #endif 00124 00125 00126 private: 00127 MutexImpl *m_impl; 00128 }; 00129 00130 } 00131 } 00132 00133 #endif