00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- 00002 //---------------------------------------------------------------------- 00014 //---------------------------------------------------------------------- 00015 #ifndef ICL_CORE_THREAD_COMMON_H_INCLUDED 00016 #define ICL_CORE_THREAD_COMMON_H_INCLUDED 00017 00018 #include "icl_core/TimeSpan.h" 00019 #include "icl_core/TimeStamp.h" 00020 00021 #ifdef _IC_BUILDER_DEPRECATED_STYLE_ 00022 # include "icl_core/Deprecate.h" 00023 #endif 00024 00025 namespace icl_core { 00029 namespace thread { 00031 namespace impl { 00032 00033 inline TimeSpan getRelativeTimeout(const TimeStamp& timeout_absolute) 00034 { 00035 TimeStamp now = TimeStamp::now(); 00036 if (timeout_absolute < now) 00037 { 00038 return TimeSpan(); 00039 } 00040 else 00041 { 00042 return timeout_absolute - now; 00043 } 00044 } 00045 00046 inline TimeStamp getAbsoluteTimeout(const TimeSpan& timeout_relative) 00047 { 00048 TimeStamp timeout_absolute = TimeStamp::now(); 00049 if (timeout_relative < TimeSpan()) 00050 { 00051 timeout_absolute += TimeSpan(365 * 86400, 0); 00052 } 00053 else 00054 { 00055 timeout_absolute += timeout_relative; 00056 } 00057 return timeout_absolute; 00058 } 00059 00061 #ifdef _IC_BUILDER_DEPRECATED_STYLE_ 00062 00063 inline TimeSpan GetRelativeTimeout(const TimeStamp& timeout_absolute) ICL_CORE_GCC_DEPRECATE_STYLE; 00064 ICL_CORE_VC_DEPRECATE_STYLE inline TimeSpan GetRelativeTimeout(const TimeStamp& timeout_absolute) 00065 { return getRelativeTimeout(timeout_absolute); } 00066 00067 inline TimeStamp GetAbsoluteTimeout(const TimeSpan& timeout_relative) ICL_CORE_GCC_DEPRECATE_STYLE; 00068 ICL_CORE_VC_DEPRECATE_STYLE inline TimeStamp GetAbsoluteTimeout(const TimeSpan& timeout_relative) 00069 { return getAbsoluteTimeout(timeout_relative); } 00070 00071 #endif 00072 00073 00074 } 00075 } 00076 } 00077 00078 #endif