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 //---------------------------------------------------------------------- 00026 //---------------------------------------------------------------------- 00027 #ifndef ICL_CORE_THREAD_SEM_H_INCLUDED 00028 #define ICL_CORE_THREAD_SEM_H_INCLUDED 00029 00030 #include <icl_core/BaseTypes.h> 00031 #include <icl_core/Noncopyable.h> 00032 #include <icl_core/TimeSpan.h> 00033 #include <icl_core/TimeStamp.h> 00034 00035 #include "icl_core_thread/ImportExport.h" 00036 00037 #ifdef _IC_BUILDER_DEPRECATED_STYLE_ 00038 # include "icl_core/Deprecate.h" 00039 #endif 00040 00041 namespace icl_core { 00042 namespace thread { 00043 00044 class SemaphoreImpl; 00045 00048 class ICL_CORE_THREAD_IMPORT_EXPORT Semaphore : protected virtual icl_core::Noncopyable 00049 { 00050 public: 00051 Semaphore(size_t initial_value); 00052 virtual ~Semaphore(); 00053 00056 void post(); 00057 00064 bool tryWait(); 00065 00072 bool wait(); 00073 00080 bool wait(const icl_core::TimeSpan& timeout); 00081 00088 bool wait(const icl_core::TimeStamp& timeout); 00089 00091 #ifdef _IC_BUILDER_DEPRECATED_STYLE_ 00092 00096 ICL_CORE_VC_DEPRECATE_STYLE void Post() ICL_CORE_GCC_DEPRECATE_STYLE; 00097 00101 ICL_CORE_VC_DEPRECATE_STYLE bool TryWait() ICL_CORE_GCC_DEPRECATE_STYLE; 00102 00106 ICL_CORE_VC_DEPRECATE_STYLE bool Wait() ICL_CORE_GCC_DEPRECATE_STYLE; 00107 00111 ICL_CORE_VC_DEPRECATE_STYLE bool Wait(const icl_core::TimeSpan& timeout) ICL_CORE_GCC_DEPRECATE_STYLE; 00112 00116 ICL_CORE_VC_DEPRECATE_STYLE bool Wait(const icl_core::TimeStamp& timeout) ICL_CORE_GCC_DEPRECATE_STYLE; 00117 00118 #endif 00119 00120 00121 private: 00122 SemaphoreImpl *m_impl; 00123 }; 00124 00125 } 00126 } 00127 00128 #endif