00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- 00002 //---------------------------------------------------------------------- 00013 //---------------------------------------------------------------------- 00014 #ifndef ICL_CORE_THREAD_SEM_H_INCLUDED 00015 #define ICL_CORE_THREAD_SEM_H_INCLUDED 00016 00017 #include <icl_core/BaseTypes.h> 00018 #include <icl_core/Noncopyable.h> 00019 #include <icl_core/TimeSpan.h> 00020 #include <icl_core/TimeStamp.h> 00021 00022 #include "icl_core_thread/ImportExport.h" 00023 00024 #ifdef _IC_BUILDER_DEPRECATED_STYLE_ 00025 # include "icl_core/Deprecate.h" 00026 #endif 00027 00028 namespace icl_core { 00029 namespace thread { 00030 00031 class SemaphoreImpl; 00032 00035 class ICL_CORE_THREAD_IMPORT_EXPORT Semaphore : protected virtual icl_core::Noncopyable 00036 { 00037 public: 00038 Semaphore(size_t initial_value); 00039 virtual ~Semaphore(); 00040 00043 void post(); 00044 00051 bool tryWait(); 00052 00059 bool wait(); 00060 00067 bool wait(const icl_core::TimeSpan& timeout); 00068 00075 bool wait(const icl_core::TimeStamp& timeout); 00076 00078 #ifdef _IC_BUILDER_DEPRECATED_STYLE_ 00079 00083 ICL_CORE_VC_DEPRECATE_STYLE void Post() ICL_CORE_GCC_DEPRECATE_STYLE; 00084 00088 ICL_CORE_VC_DEPRECATE_STYLE bool TryWait() ICL_CORE_GCC_DEPRECATE_STYLE; 00089 00093 ICL_CORE_VC_DEPRECATE_STYLE bool Wait() ICL_CORE_GCC_DEPRECATE_STYLE; 00094 00098 ICL_CORE_VC_DEPRECATE_STYLE bool Wait(const icl_core::TimeSpan& timeout) ICL_CORE_GCC_DEPRECATE_STYLE; 00099 00103 ICL_CORE_VC_DEPRECATE_STYLE bool Wait(const icl_core::TimeStamp& timeout) ICL_CORE_GCC_DEPRECATE_STYLE; 00104 00105 #endif 00106 00107 00108 private: 00109 SemaphoreImpl *m_impl; 00110 }; 00111 00112 } 00113 } 00114 00115 #endif