#include <Time_Value.h>
Collaboration diagram for ACE_Time_Value:
Public Member Functions | |
ACE_Time_Value (void) | |
Default Constructor. | |
ACE_Time_Value (time_t sec, suseconds_t usec=0) | |
Constructor. | |
ACE_Time_Value (const struct timeval &t) | |
Construct the ACE_Time_Value from a timeval. | |
ACE_Time_Value (const timespec_t &t) | |
Construct the ACE_Time_Value object from a timespec_t. | |
ACE_Time_Value (const FILETIME &ft) | |
Construct the ACE_Time_Value object from a Win32 FILETIME. | |
void | set (time_t sec, suseconds_t usec) |
Initializes the ACE_Time_Value from seconds and useconds. | |
void | set (double d) |
void | set (const timeval &t) |
Initializes the ACE_Time_Value from a timeval. | |
void | set (const timespec_t &t) |
Initializes the ACE_Time_Value object from a timespec_t. | |
void | set (const FILETIME &ft) |
Initializes the ACE_Time_Value object from a Win32 FILETIME. | |
unsigned long | msec (void) const |
Converts from ACE_Time_Value format into milli-seconds format. | |
void | msec (ACE_UINT64 &ms) const |
void | msec (long) |
Converts from milli-seconds format into ACE_Time_Value format. | |
operator timespec_t () const | |
Returns the value of the object as a timespec_t. | |
operator timeval () const | |
Returns the value of the object as a timeval. | |
operator const timeval * () const | |
Returns a pointer to the object as a timeval. | |
operator FILETIME () const | |
Returns the value of the object as a Win32 FILETIME. | |
time_t | sec (void) const |
Get seconds. | |
void | sec (time_t sec) |
Set seconds. | |
suseconds_t | usec (void) const |
Get microseconds. | |
void | usec (suseconds_t usec) |
Set microseconds. | |
void | to_usec (ACE_UINT64 &usec) const |
ACE_Time_Value & | operator+= (const ACE_Time_Value &tv) |
Add tv to this. | |
ACE_Time_Value & | operator+= (time_t tv) |
Add tv to this. | |
ACE_Time_Value & | operator= (const ACE_Time_Value &tv) |
Assign @ tv to this. | |
ACE_Time_Value & | operator= (time_t tv) |
Assign @ tv to this. | |
ACE_Time_Value & | operator-= (const ACE_Time_Value &tv) |
Subtract tv to this. | |
ACE_Time_Value & | operator-= (time_t tv) |
Substract tv to this. | |
ACE_Time_Value & | operator *= (double d) |
Multiply the time value by the d factor. | |
ACE_Time_Value | operator++ (int) |
Increment microseconds as postfix. | |
ACE_Time_Value & | operator++ (void) |
Increment microseconds as prefix. | |
ACE_Time_Value | operator-- (int) |
Decrement microseconds as postfix. | |
ACE_Time_Value & | operator-- (void) |
Decrement microseconds as prefix. | |
void | dump (void) const |
Dump is a no-op. | |
Static Public Attributes | |
const ACE_Time_Value | zero |
Constant "0". | |
const ACE_Time_Value | max_time |
const DWORDLONG | FILETIME_to_timval_skew |
Const time difference between FILETIME and POSIX time. | |
Private Member Functions | |
void | normalize (void) |
Put the timevalue into a canonical form. | |
Private Attributes | |
timeval | tv_ |
Store the values as a timeval. | |
Friends | |
ACE_Export ACE_Time_Value | operator+ (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2) |
Adds two ACE_Time_Value objects together, returns the sum. | |
ACE_Export ACE_Time_Value | operator- (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2) |
Subtracts two ACE_Time_Value objects, returns the difference. | |
ACE_Export bool | operator< (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2) |
True if tv1 < tv2. | |
ACE_Export bool | operator> (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2) |
True if tv1 > tv2. | |
ACE_Export bool | operator<= (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2) |
True if tv1 <= tv2. | |
ACE_Export bool | operator>= (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2) |
True if tv1 >= tv2. | |
ACE_Export bool | operator== (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2) |
True if tv1 == tv2. | |
ACE_Export bool | operator!= (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2) |
True if tv1 != tv2. | |
ACE_Export ACE_Time_Value | operator * (double d, const ACE_Time_Value &tv) |
Multiplies the time value by d. | |
ACE_Export ACE_Time_Value | operator * (const ACE_Time_Value &tv, double d) |
Multiplies the time value by d. |
This class centralizes all the time related processing in ACE. These time values are typically used in conjunction with OS mechanisms like , , or .
Definition at line 66 of file Time_Value.h.
|
Default Constructor.
Definition at line 102 of file Time_Value.inl. References set().
|
|
Constructor.
Definition at line 110 of file Time_Value.inl. References set().
00111 { 00112 // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value"); 00113 this->set (sec, usec); 00114 } |
|
Construct the ACE_Time_Value from a timeval.
Definition at line 37 of file Time_Value.inl. References set().
|
|
Construct the ACE_Time_Value object from a timespec_t.
Definition at line 267 of file Time_Value.inl. References set(), and timespec_t.
|
|
Construct the ACE_Time_Value object from a Win32 FILETIME.
Definition at line 108 of file Time_Value.cpp. References set().
00109 { 00110 // // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value"); 00111 this->set (file_time); 00112 } |
|
Dump is a no-op.
The dump() method is a no-op. It's here for backwards compatibility only, but does not dump anything. Invoking logging methods here violates layering restrictions in ACE because this class is part of the OS layer and Definition at line 171 of file Time_Value.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, and LM_DEBUG. Referenced by ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::dump(), and ACE_Timer_Node_T< TYPE >::dump().
00172 { 00173 #if defined (ACE_HAS_DUMP) 00174 // ACE_OS_TRACE ("ACE_Time_Value::dump"); 00175 #if 0 00176 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); 00177 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\ntv_sec_ = %d"), this->tv_.tv_sec)); 00178 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\ntv_usec_ = %d\n"), this->tv_.tv_usec)); 00179 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); 00180 #endif /* 0 */ 00181 #endif /* ACE_HAS_DUMP */ 00182 } |
|
Converts from milli-seconds format into ACE_Time_Value format.
Definition at line 169 of file Time_Value.inl. References tv_.
|
|
Definition at line 157 of file Time_Value.inl. References ACE_UINT64, and tv_.
|
|
|
Put the timevalue into a canonical form.
Definition at line 185 of file Time_Value.cpp. References ACE_ONE_SECOND_IN_USECS, and tv_. Referenced by operator++(), operator+=(), operator--(), operator-=(), and set().
00186 { 00187 // // ACE_OS_TRACE ("ACE_Time_Value::normalize"); 00188 // From Hans Rohnert... 00189 00190 if (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS) 00191 { 00192 /*! \todo This loop needs some optimization. 00193 */ 00194 do 00195 { 00196 ++this->tv_.tv_sec; 00197 this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS; 00198 } 00199 while (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS); 00200 } 00201 else if (this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS) 00202 { 00203 /*! \todo This loop needs some optimization. 00204 */ 00205 do 00206 { 00207 --this->tv_.tv_sec; 00208 this->tv_.tv_usec += ACE_ONE_SECOND_IN_USECS; 00209 } 00210 while (this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS); 00211 } 00212 00213 if (this->tv_.tv_sec >= 1 && this->tv_.tv_usec < 0) 00214 { 00215 --this->tv_.tv_sec; 00216 this->tv_.tv_usec += ACE_ONE_SECOND_IN_USECS; 00217 } 00218 // tv_sec in qnxnto is unsigned 00219 #if !defined ( __QNXNTO__) 00220 else if (this->tv_.tv_sec < 0 && this->tv_.tv_usec > 0) 00221 { 00222 ++this->tv_.tv_sec; 00223 this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS; 00224 } 00225 #endif /* __QNXNTO__ */ 00226 } |
|
Multiply the time value by the d factor.
Definition at line 230 of file Time_Value.cpp. References ACE_ONE_SECOND_IN_USECS, sec(), set(), and usec().
00231 { 00232 // double is long enough (16 digits) to not lose the accuracy. 00233 double time_total = 00234 (this->sec () 00235 + static_cast<double> (this->usec ()) / ACE_ONE_SECOND_IN_USECS) * d; 00236 00237 // shall we saturate the result? 00238 #if !defined(ACE_LACKS_NUMERIC_LIMITS) && !defined (ACE_WIN64) 00239 static const double max_int = std::numeric_limits<time_t>::max () + 0.999999; 00240 static const double min_int = std::numeric_limits<time_t>::min () - 0.999999; 00241 #else 00242 static const double max_int = LONG_MAX + 0.999999; 00243 static const double min_int = LONG_MIN - 0.999999; 00244 #endif 00245 00246 if (time_total > max_int) 00247 time_total = max_int; 00248 if (time_total < min_int) 00249 time_total = min_int; 00250 00251 const time_t time_sec = static_cast<time_t> (time_total); 00252 00253 time_total -= time_sec; 00254 time_total *= ACE_ONE_SECOND_IN_USECS; 00255 00256 suseconds_t time_usec = static_cast<suseconds_t> (time_total); 00257 00258 // round up the result to save the last usec 00259 if (time_usec > 0 && (time_total - time_usec) >= 0.5) 00260 ++time_usec; 00261 else if (time_usec < 0 && (time_total - time_usec) <= -0.5) 00262 --time_usec; 00263 00264 this->set (time_sec, time_usec); 00265 00266 return *this; 00267 } |
|
Returns a pointer to the object as a timeval.
Definition at line 45 of file Time_Value.inl. References tv_.
00046 { 00047 // ACE_OS_TRACE ("ACE_Time_Value::operator const timeval *"); 00048 return (const timeval *) &this->tv_; 00049 } |
|
Returns the value of the object as a Win32 FILETIME.
Definition at line 142 of file Time_Value.cpp. References FILETIME_to_timval_skew, and tv_.
00143 { 00144 FILETIME file_time; 00145 // ACE_OS_TRACE ("ACE_Time_Value::operator FILETIME"); 00146 00147 #if defined (ACE_LACKS_LONGLONG_T) 00148 ACE_U_LongLong LL_sec(this->tv_.tv_sec); 00149 ACE_U_LongLong LL_usec(this->tv_.tv_usec); 00150 ACE_U_LongLong LL_100ns = LL_sec * (ACE_UINT32)(10000 * 1000) + 00151 LL_usec * (ACE_UINT32)10 + 00152 ACE_Time_Value::FILETIME_to_timval_skew; 00153 file_time.dwLowDateTime = LL_100ns.lo(); 00154 file_time.dwHighDateTime = LL_100ns.hi(); 00155 #else 00156 ULARGE_INTEGER _100ns; 00157 _100ns.QuadPart = (((DWORDLONG) this->tv_.tv_sec * (10000 * 1000) + 00158 this->tv_.tv_usec * 10) + 00159 ACE_Time_Value::FILETIME_to_timval_skew); 00160 00161 file_time.dwLowDateTime = _100ns.LowPart; 00162 file_time.dwHighDateTime = _100ns.HighPart; 00163 #endif //ACE_LACKS_LONGLONG_T 00164 00165 return file_time; 00166 } |
|
Returns the value of the object as a timespec_t.
Definition at line 254 of file Time_Value.inl. References sec(), timespec_t, tv_, timespec::tv_nsec, and timespec::tv_sec.
00255 { 00256 // ACE_OS_TRACE ("ACE_Time_Value::operator timespec_t"); 00257 timespec_t tv; 00258 tv.tv_sec = this->sec (); 00259 // Convert microseconds into nanoseconds. 00260 tv.tv_nsec = this->tv_.tv_usec * 1000; 00261 return tv; 00262 } |
|
Returns the value of the object as a timeval.
Definition at line 20 of file Time_Value.inl. References tv_.
00021 { 00022 // ACE_OS_TRACE ("ACE_Time_Value::operator timeval"); 00023 return this->tv_; 00024 } |
|
Increment microseconds as prefix.
Definition at line 61 of file Time_Value.cpp. References normalize(), and usec().
|
|
Increment microseconds as postfix.
Definition at line 52 of file Time_Value.cpp.
00053 { 00054 // ACE_OS_TRACE ("ACE_Time_Value::operator ++ (int)"); 00055 ACE_Time_Value tv (*this); 00056 ++*this; 00057 return tv; 00058 } |
|
Add tv to this.
Definition at line 328 of file Time_Value.inl. References sec().
00329 { 00330 // ACE_OS_TRACE ("ACE_Time_Value::operator+="); 00331 this->sec (this->sec () + tv); 00332 return *this; 00333 } |
|
Add tv to this.
Definition at line 318 of file Time_Value.inl. References normalize(), sec(), and usec().
|
|
Decrement microseconds as prefix.
Definition at line 82 of file Time_Value.cpp. References normalize(), and usec().
|
|
Decrement microseconds as postfix.
Definition at line 73 of file Time_Value.cpp.
00074 { 00075 // ACE_OS_TRACE ("ACE_Time_Value::operator -- (int)"); 00076 ACE_Time_Value tv (*this); 00077 --*this; 00078 return tv; 00079 } |
|
Substract tv to this.
Definition at line 366 of file Time_Value.inl. References sec().
00367 { 00368 // ACE_OS_TRACE ("ACE_Time_Value::operator-="); 00369 this->sec (this->sec () - tv); 00370 return *this; 00371 } |
|
Subtract tv to this.
Definition at line 356 of file Time_Value.inl. References normalize(), sec(), and usec().
|
|
Assign @ tv to this.
Definition at line 345 of file Time_Value.inl.
|
|
Assign @ tv to this.
Definition at line 336 of file Time_Value.inl.
|
|
Set seconds.
Definition at line 128 of file Time_Value.inl. References tv_.
00129 { 00130 // ACE_OS_TRACE ("ACE_Time_Value::sec"); 00131 #if defined (ACE_WIN64) \ 00132 || (defined (ACE_WIN32) && !defined (_USE_32BIT_TIME_T)) 00133 // Win64 uses 'long' (32 bit) timeval and 64-bit time_t, so we have 00134 // to get these back in range. 00135 if (sec > LONG_MAX) 00136 this->tv_.tv_sec = LONG_MAX; 00137 else if (sec < LONG_MIN) 00138 this->tv_.tv_sec = LONG_MIN; 00139 else 00140 this->tv_.tv_sec = static_cast<long> (sec); 00141 #else 00142 this->tv_.tv_sec = sec; 00143 #endif 00144 } |
|
|
Initializes the ACE_Time_Value object from a Win32 FILETIME.
Definition at line 114 of file Time_Value.cpp. References FILETIME_to_timval_skew, normalize(), and tv_.
00115 { 00116 // Initializes the ACE_Time_Value object from a Win32 FILETIME 00117 #if defined (ACE_LACKS_LONGLONG_T) 00118 ACE_U_LongLong LL_100ns(file_time.dwLowDateTime, file_time.dwHighDateTime); 00119 LL_100ns -= ACE_Time_Value::FILETIME_to_timval_skew; 00120 // Convert 100ns units to seconds; 00121 this->tv_.tv_sec = (long) (LL_100ns / ((double) (10000 * 1000))); 00122 // Convert remainder to microseconds; 00123 this->tv_.tv_usec = (suseconds_t)((LL_100ns % ((ACE_UINT32)(10000 * 1000))) / 10); 00124 #else 00125 // Don't use a struct initializer, gcc don't like it. 00126 ULARGE_INTEGER _100ns; 00127 _100ns.LowPart = file_time.dwLowDateTime; 00128 _100ns.HighPart = file_time.dwHighDateTime; 00129 00130 _100ns.QuadPart -= ACE_Time_Value::FILETIME_to_timval_skew; 00131 00132 // Convert 100ns units to seconds; 00133 this->tv_.tv_sec = (long) (_100ns.QuadPart / (10000 * 1000)); 00134 // Convert remainder to microseconds; 00135 this->tv_.tv_usec = (suseconds_t) ((_100ns.QuadPart % (10000 * 1000)) / 10); 00136 #endif // ACE_LACKS_LONGLONG_T 00137 this->normalize (); 00138 } |
|
Initializes the ACE_Time_Value object from a timespec_t.
Definition at line 93 of file Time_Value.inl. References set(), timespec_t, timespec::tv_nsec, and timespec::tv_sec.
|
|
Initializes the ACE_Time_Value from a timeval.
Definition at line 27 of file Time_Value.inl. References normalize(), and tv_.
|
|
Initializes the ACE_Time_Value from a double, which is assumed to be in second format, with any remainder treated as microseconds. Definition at line 79 of file Time_Value.inl. References ACE_ONE_SECOND_IN_USECS, normalize(), and tv_.
00080 { 00081 // ACE_OS_TRACE ("ACE_Time_Value::set"); 00082 long l = (long) d; 00083 this->tv_.tv_sec = l; 00084 this->tv_.tv_usec = (suseconds_t) ((d - (double) l) * ACE_ONE_SECOND_IN_USECS + .5); 00085 this->normalize (); 00086 } |
|
Initializes the ACE_Time_Value from seconds and useconds.
Definition at line 52 of file Time_Value.inl. References ACE_ONE_SECOND_IN_USECS, normalize(), and tv_. Referenced by ACE_Time_Value(), ACE_System_Time::get_local_system_time(), operator *=(), ACE_Metrics_Cache< ACE_LOCK, ALLOCATOR >::report_dequeue_start(), ACE_Metrics_Cache< ACE_LOCK, ALLOCATOR >::report_enqueue_start(), ACE_Metrics_Cache< ACE_LOCK, ALLOCATOR >::reset_base_statistics(), and set().
00053 { 00054 // ACE_OS_TRACE ("ACE_Time_Value::set"); 00055 #if defined (ACE_WIN64) \ 00056 || (defined (ACE_WIN32) && !defined (_USE_32BIT_TIME_T)) 00057 // Win64 uses 'long' (32 bit) timeval and 64-bit time_t, so we have 00058 // to get these back in range. 00059 if (sec > LONG_MAX) 00060 this->tv_.tv_sec = LONG_MAX; 00061 else if (sec < LONG_MIN) 00062 this->tv_.tv_sec = LONG_MIN; 00063 else 00064 this->tv_.tv_sec = static_cast<long> (sec); 00065 #else 00066 this->tv_.tv_sec = sec; 00067 #endif 00068 this->tv_.tv_usec = usec; 00069 #if __GNUC__ 00070 if (__builtin_constant_p(sec) && 00071 __builtin_constant_p(usec) && 00072 (sec >= 0 && usec >= 0 && usec < ACE_ONE_SECOND_IN_USECS)) 00073 return; 00074 #endif 00075 this->normalize (); 00076 } |
|
Definition at line 198 of file Time_Value.inl. References ACE_UINT64, and tv_. Referenced by ACE_Utils::UUID_Generator::get_systemtime().
|
|
Set microseconds.
Definition at line 190 of file Time_Value.inl. References tv_.
00191 { 00192 // ACE_OS_TRACE ("ACE_Time_Value::usec"); 00193 this->tv_.tv_usec = usec; 00194 } |
|
|
Multiplies the time value by d.
Definition at line 214 of file Time_Value.inl.
00215 { 00216 return ACE_Time_Value (tv) *= d; 00217 } |
|
Multiplies the time value by d.
Definition at line 208 of file Time_Value.inl.
00209 { 00210 return ACE_Time_Value (tv) *= d; 00211 } |
|
True if tv1 != tv2.
Definition at line 308 of file Time_Value.inl.
00310 { 00311 // ACE_OS_TRACE ("operator !="); 00312 return !(tv1 == tv2); 00313 } |
|
Adds two ACE_Time_Value objects together, returns the sum.
Definition at line 376 of file Time_Value.inl.
00378 { 00379 // ACE_OS_TRACE ("operator +"); 00380 ACE_Time_Value sum (tv1); 00381 sum += tv2; 00382 00383 return sum; 00384 } |
|
Subtracts two ACE_Time_Value objects, returns the difference.
Definition at line 389 of file Time_Value.inl.
00391 { 00392 // ACE_OS_TRACE ("operator -"); 00393 ACE_Time_Value delta (tv1); 00394 delta -= tv2; 00395 00396 return delta; 00397 } |
|
True if tv1 < tv2.
Definition at line 277 of file Time_Value.inl.
00279 { 00280 // ACE_OS_TRACE ("operator <"); 00281 return tv2 > tv1; 00282 } |
|
True if tv1 <= tv2.
Definition at line 287 of file Time_Value.inl.
00289 { 00290 // ACE_OS_TRACE ("operator <="); 00291 return tv2 >= tv1; 00292 } |
|
True if tv1 == tv2.
Definition at line 297 of file Time_Value.inl.
|
|
True if tv1 > tv2.
Definition at line 222 of file Time_Value.inl.
|
|
True if tv1 >= tv2.
Definition at line 238 of file Time_Value.inl.
|
|
Initial value: ACE_INT64_LITERAL (0x19db1ded53e8000)
Definition at line 102 of file Time_Value.cpp. Referenced by operator FILETIME(), and set(). |
|
Constant for maximum time representable. Note that this time is not intended for use with or other calls that may have *their own* implementation-specific maximum time representations. Its primary use is in time computations such as those used by the dynamic subpriority strategies in the ACE_Dynamic_Message_Queue class. |
|
Store the values as a timeval.
Definition at line 325 of file Time_Value.h. Referenced by msec(), normalize(), operator const timeval *(), operator FILETIME(), operator timespec_t(), operator timeval(), sec(), set(), to_usec(), and usec(). |
|
Constant "0".
Definition at line 28 of file Time_Value.cpp. |