#include <Time_Value.h>
Collaboration diagram for ACE_Time_Value:

Public Methods | |
| ACE_Time_Value (void) | |
| Default Constructor. More... | |
| ACE_Time_Value (long sec, long usec=0) | |
| Constructor. More... | |
| ACE_Time_Value (const struct timeval &t) | |
| Construct the ACE_Time_Value from a timeval. More... | |
| ACE_Time_Value (const timespec_t &t) | |
| Construct the ACE_Time_Value object from a timespec_t. More... | |
| ACE_Time_Value (const FILETIME &ft) | |
| Construct the ACE_Time_Value object from a Win32 FILETIME. More... | |
| void | set (long sec, long usec) |
| Initializes the ACE_Time_Value from two longs. More... | |
| void | set (double d) |
| Initializes the ACE_Time_Value from a double, which is assumed to be in second format, with any remainder treated as microseconds. More... | |
| void | set (const timeval &t) |
| Initializes the ACE_Time_Value from a timeval. More... | |
| void | set (const timespec_t &t) |
| Initializes the ACE_Time_Value object from a timespec_t. More... | |
| void | set (const FILETIME &ft) |
| Initializes the ACE_Time_Value object from a Win32 FILETIME. More... | |
| long | msec (void) const |
| Converts from ACE_Time_Value format into milli-seconds format. More... | |
| void | msec (long) |
| Converts from milli-seconds format into ACE_Time_Value format. More... | |
| operator timespec_t () const | |
| Returns the value of the object as a timespec_t. More... | |
| operator timeval () const | |
| Returns the value of the object as a timeval. More... | |
| operator const timeval * () const | |
| Returns a pointer to the object as a timeval. More... | |
| operator FILETIME () const | |
| Returns the value of the object as a Win32 FILETIME. More... | |
| long | sec (void) const |
| Get seconds. More... | |
| void | sec (long sec) |
| Set seconds. More... | |
| long | usec (void) const |
| Get microseconds. More... | |
| void | usec (long usec) |
| Set microseconds. More... | |
| ACE_Time_Value & | operator+= (const ACE_Time_Value &tv) |
| Add tv to this. More... | |
| ACE_Time_Value & | operator-= (const ACE_Time_Value &tv) |
| Subtract tv to this. More... | |
| ACE_Time_Value & | operator *= (double d) |
| Multiply the time value by the d factor, which must be >= 0. More... | |
| ACE_Time_Value | operator++ (int) |
| Increment microseconds as postfix. More... | |
| ACE_Time_Value & | operator++ (void) |
| Increment microseconds as prefix. More... | |
| ACE_Time_Value | operator-- (int) |
| Decrement microseconds as postfix. More... | |
| ACE_Time_Value & | operator-- (void) |
| Decrement microseconds as prefix. More... | |
| void | dump (void) const |
| Dump is a no-op. More... | |
Static Public Attributes | |
| const ACE_Time_Value | zero |
| Constant "0". More... | |
| const ACE_Time_Value | max_time |
| const DWORDLONG | FILETIME_to_timval_skew |
| Const time difference between FILETIME and POSIX time. More... | |
Private Methods | |
| void | normalize (void) |
| Put the timevalue into a canonical form. More... | |
Private Attributes | |
| timeval | tv_ |
| Store the values as a timeval. More... | |
Friends | |
| ACE_OS_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. More... | |
| ACE_OS_Export ACE_Time_Value | operator- (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2) |
| Subtracts two ACE_Time_Value objects, returns the difference. More... | |
| ACE_OS_Export int | operator< (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2) |
| True if tv1 < tv2. More... | |
| ACE_OS_Export int | operator> (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2) |
| True if tv1 > tv2. More... | |
| ACE_OS_Export int | operator<= (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2) |
| True if tv1 <= tv2. More... | |
| ACE_OS_Export int | operator>= (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2) |
| True if tv1 >= tv2. More... | |
| ACE_OS_Export int | operator== (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2) |
| True if tv1 == tv2. More... | |
| ACE_OS_Export int | operator!= (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2) |
| True if tv1 != tv2. More... | |
| ACE_OS_Export ACE_Time_Value | operator * (double d, const ACE_Time_Value &tv) |
| Multiplies the time value by d. More... | |
| ACE_OS_Export ACE_Time_Value | operator * (const ACE_Time_Value &tv, double d) |
| Multiplies the time value by d. More... | |
This class centralizes all the time related processing in ACE. These time values are typically used in conjunction with OS mechanisms like <select>, <poll>, or <cond_timedwait>.
Definition at line 103 of file Time_Value.h.
|
|
Default Constructor.
Definition at line 83 of file Time_Value.inl.
|
|
||||||||||||
|
Constructor.
Definition at line 91 of file Time_Value.inl. References sec, set, and usec.
|
|
|
Construct the ACE_Time_Value from a timeval.
Definition at line 75 of file Time_Value.inl.
|
|
|
Construct the ACE_Time_Value object from a timespec_t.
Definition at line 232 of file Time_Value.inl.
|
|
|
Construct the ACE_Time_Value object from a Win32 FILETIME.
Definition at line 91 of file Time_Value.cpp. References set.
00092 {
00093 // // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value");
00094 this->set (file_time);
00095 }
|
|
|
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 154 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::dump, and ACE_Timer_Node_T::dump.
00155 {
00156 // ACE_OS_TRACE ("ACE_Time_Value::dump");
00157 #if 0
00158 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00159 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\ntv_sec_ = %d"), this->tv_.tv_sec));
00160 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\ntv_usec_ = %d\n"), this->tv_.tv_usec));
00161 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00162 #endif /* 0 */
00163 }
|
|
|
Converts from milli-seconds format into ACE_Time_Value format.
Definition at line 127 of file Time_Value.inl. References tv_.
|
|
|
Converts from ACE_Time_Value format into milli-seconds format.
Definition at line 118 of file Time_Value.inl. References tv_. Referenced by ACE_WFMO_Reactor::calculate_timeout, ACE_High_Res_Timer::calibrate, ACE_TLI_Connector::complete, ACE_SPIPE_Connector::connect, ACE_OS::event_timedwait, ACE_WIN32_Proactor::handle_events, ACE_POSIX_AIOCB_Proactor::handle_events, ACE_POSIX_CB_Proactor::handle_events, ACE_OS::mutex_lock, ACE_WFMO_Reactor::ok_to_wait, ACE_OS::poll, ACE_XtReactor::reset_timeout, ACE_TkReactor::reset_timeout, ACE_QtReactor::reset_timeout, ACE_OS::sched_params, ACE_OS::sema_wait, ACE_OS::sleep, ACE_NT_Service::state, ACE_Process_Manager::wait, ACE_Process::wait, and ACE_Dev_Poll_Reactor::work_pending_i.
|
|
|
Put the timevalue into a canonical form.
Definition at line 166 of file Time_Value.cpp. References ACE_ONE_SECOND_IN_USECS, and tv_. Referenced by operator *=, operator+, operator++, operator+=, operator-, operator--, operator-=, and set.
00167 {
00168 // // ACE_OS_TRACE ("ACE_Time_Value::normalize");
00169 // From Hans Rohnert...
00170
00171 if (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS)
00172 {
00173 do
00174 {
00175 this->tv_.tv_sec++;
00176 this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS;
00177 }
00178 while (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS);
00179 }
00180 else if (this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS)
00181 {
00182 do
00183 {
00184 this->tv_.tv_sec--;
00185 this->tv_.tv_usec += ACE_ONE_SECOND_IN_USECS;
00186 }
00187 while (this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS);
00188 }
00189
00190 if (this->tv_.tv_sec >= 1 && this->tv_.tv_usec < 0)
00191 {
00192 this->tv_.tv_sec--;
00193 this->tv_.tv_usec += ACE_ONE_SECOND_IN_USECS;
00194 }
00195 else if (this->tv_.tv_sec < 0 && this->tv_.tv_usec > 0)
00196 {
00197 this->tv_.tv_sec++;
00198 this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS;
00199 }
00200 }
|
|
|
Multiply the time value by the d factor, which must be >= 0.
Definition at line 155 of file Time_Value.inl. References ACE_ONE_SECOND_IN_USECS, normalize, sec, and usec.
00156 {
00157 double time =
00158 ((double) this->sec ()) * ACE_ONE_SECOND_IN_USECS + this->usec ();
00159 time *= d;
00160 this->sec ((long)(time / ACE_ONE_SECOND_IN_USECS));
00161 this->usec (((long)time) % ACE_ONE_SECOND_IN_USECS);
00162 this->normalize ();
00163 return *this;
00164 }
|
|
|
Returns a pointer to the object as a timeval.
Definition at line 18 of file Time_Value.inl. References tv_.
00019 {
00020 // ACE_OS_TRACE ("ACE_Time_Value::operator const timeval *");
00021 return (const timeval *) &this->tv_;
00022 }
|
|
|
Returns the value of the object as a Win32 FILETIME.
Definition at line 125 of file Time_Value.cpp. References FILETIME_to_timval_skew, and tv_.
00126 {
00127 FILETIME file_time;
00128 // ACE_OS_TRACE ("ACE_Time_Value::operator FILETIME");
00129
00130 #if defined (ACE_LACKS_LONGLONG_T)
00131 ACE_U_LongLong LL_sec(this->tv_.tv_sec);
00132 ACE_U_LongLong LL_usec(this->tv_.tv_usec);
00133 ACE_U_LongLong LL_100ns = LL_sec * (ACE_UINT32)(10000 * 1000) +
00134 LL_usec * (ACE_UINT32)10 +
00135 ACE_Time_Value::FILETIME_to_timval_skew;
00136 file_time.dwLowDateTime = LL_100ns.lo();
00137 file_time.dwHighDateTime = LL_100ns.hi();
00138 #else
00139 ULARGE_INTEGER _100ns;
00140 _100ns.QuadPart = (((DWORDLONG) this->tv_.tv_sec * (10000 * 1000) +
00141 this->tv_.tv_usec * 10) +
00142 ACE_Time_Value::FILETIME_to_timval_skew);
00143
00144 file_time.dwLowDateTime = _100ns.LowPart;
00145 file_time.dwHighDateTime = _100ns.HighPart;
00146 #endif //ACE_LACKS_LONGLONG_T
00147
00148 return file_time;
00149 }
|
|
|
Returns the value of the object as a timespec_t.
Definition at line 213 of file Time_Value.inl. References sec, tv_, timespec::tv_nsec, and timespec::tv_sec.
00214 {
00215 // ACE_OS_TRACE ("ACE_Time_Value::operator timespec_t");
00216 timespec_t tv;
00217 #if ! defined(ACE_HAS_BROKEN_TIMESPEC_MEMBERS)
00218 tv.tv_sec = this->sec ();
00219 // Convert microseconds into nanoseconds.
00220 tv.tv_nsec = this->tv_.tv_usec * 1000;
00221 #else
00222 tv.ts_sec = this->sec ();
00223 // Convert microseconds into nanoseconds.
00224 tv.ts_nsec = this->tv_.tv_usec * 1000;
00225 #endif /* ACE_HAS_BROKEN_TIMESPEC_MEMBERS */
00226 return tv;
00227 }
|
|
|
Returns the value of the object as a timeval.
Definition at line 9 of file Time_Value.inl. References tv_.
00010 {
00011 // ACE_OS_TRACE ("ACE_Time_Value::operator timeval");
00012 return this->tv_;
00013 }
|
|
|
Increment microseconds as prefix.
Definition at line 44 of file Time_Value.cpp. References normalize, and usec.
|
|
|
Increment microseconds as postfix.
Definition at line 35 of file Time_Value.cpp.
00036 {
00037 // ACE_OS_TRACE ("ACE_Time_Value::operator ++ (int)");
00038 ACE_Time_Value tv (*this);
00039 ++*this;
00040 return tv;
00041 }
|
|
|
Add tv to this.
Definition at line 283 of file Time_Value.inl. References normalize, sec, and usec.
|
|
|
Decrement microseconds as prefix.
Definition at line 65 of file Time_Value.cpp. References normalize, and usec.
|
|
|
Decrement microseconds as postfix.
Definition at line 56 of file Time_Value.cpp.
00057 {
00058 // ACE_OS_TRACE ("ACE_Time_Value::operator -- (int)");
00059 ACE_Time_Value tv (*this);
00060 --*this;
00061 return tv;
00062 }
|
|
|
Subtract tv to this.
Definition at line 295 of file Time_Value.inl. References normalize, sec, and usec.
|
|
|
Set seconds.
Definition at line 109 of file Time_Value.inl.
|
|
|
|
Initializes the ACE_Time_Value object from a Win32 FILETIME.
Definition at line 97 of file Time_Value.cpp. References FILETIME_to_timval_skew, normalize, and tv_.
00098 {
00099 // Initializes the ACE_Time_Value object from a Win32 FILETIME
00100 #if defined (ACE_LACKS_LONGLONG_T)
00101 ACE_U_LongLong LL_100ns(file_time.dwLowDateTime, file_time.dwHighDateTime);
00102 LL_100ns -= ACE_Time_Value::FILETIME_to_timval_skew;
00103 // Convert 100ns units to seconds;
00104 this->tv_.tv_sec = (long) (LL_100ns / ((double) (10000 * 1000)));
00105 // Convert remainder to microseconds;
00106 this->tv_.tv_usec = (long)((LL_100ns % ((ACE_UINT32)(10000 * 1000))) / 10);
00107 #else
00108 // Don't use a struct initializer, gcc don't like it.
00109 ULARGE_INTEGER _100ns;
00110 _100ns.LowPart = file_time.dwLowDateTime;
00111 _100ns.HighPart = file_time.dwHighDateTime;
00112
00113 _100ns.QuadPart -= ACE_Time_Value::FILETIME_to_timval_skew;
00114
00115 // Convert 100ns units to seconds;
00116 this->tv_.tv_sec = (long) (_100ns.QuadPart / (10000 * 1000));
00117 // Convert remainder to microseconds;
00118 this->tv_.tv_usec = (long) ((_100ns.QuadPart % (10000 * 1000)) / 10);
00119 #endif // ACE_LACKS_LONGLONG_T
00120 this->normalize ();
00121 }
|
|
|
Initializes the ACE_Time_Value object from a timespec_t.
Definition at line 48 of file Time_Value.inl. References normalize, tv_, timespec::tv_nsec, and timespec::tv_sec.
00049 {
00050 // ACE_OS_TRACE ("ACE_Time_Value::set");
00051 #if ! defined(ACE_HAS_BROKEN_TIMESPEC_MEMBERS)
00052 this->tv_.tv_sec = ACE_static_cast (long, tv.tv_sec);
00053 // Convert nanoseconds into microseconds.
00054 this->tv_.tv_usec = tv.tv_nsec / 1000;
00055 #else
00056 this->tv_.tv_sec = tv.ts_sec;
00057 // Convert nanoseconds into microseconds.
00058 this->tv_.tv_usec = tv.ts_nsec / 1000;
00059 #endif /* ACE_HAS_BROKEN_TIMESPEC_MEMBERS */
00060
00061 this->normalize ();
00062 }
|
|
|
Initializes the ACE_Time_Value from a timeval.
Definition at line 65 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 34 of file Time_Value.inl. References ACE_ONE_SECOND_IN_USECS, normalize, and tv_.
00035 {
00036 // ACE_OS_TRACE ("ACE_Time_Value::set");
00037 long l = (long) d;
00038 this->tv_.tv_sec = l;
00039 this->tv_.tv_usec = (long) ((d - (double) l) * ACE_ONE_SECOND_IN_USECS);
00040 this->normalize ();
00041 }
|
|
||||||||||||
|
Initializes the ACE_Time_Value from two longs.
Definition at line 25 of file Time_Value.inl. References normalize, sec, tv_, and usec. Referenced by ACE_Time_Value, and ACE_OS::cond_timedwait.
|
|
|
Set microseconds.
Definition at line 148 of file Time_Value.inl.
|
|
|
||||||||||||
|
Multiplies the time value by d.
Definition at line 173 of file Time_Value.inl.
00174 {
00175 return ACE_Time_Value (tv) *= d;
00176 }
|
|
||||||||||||
|
Multiplies the time value by d.
Definition at line 167 of file Time_Value.inl.
00168 {
00169 return ACE_Time_Value (tv) *= d;
00170 }
|
|
||||||||||||
|
True if tv1 != tv2.
Definition at line 273 of file Time_Value.inl.
00275 {
00276 // ACE_OS_TRACE ("operator !=");
00277 return !(tv1 == tv2);
00278 }
|
|
||||||||||||
|
Adds two ACE_Time_Value objects together, returns the sum.
Definition at line 307 of file Time_Value.inl.
|
|
||||||||||||
|
Subtracts two ACE_Time_Value objects, returns the difference.
Definition at line 321 of file Time_Value.inl.
|
|
||||||||||||
|
True if tv1 < tv2.
Definition at line 242 of file Time_Value.inl.
00244 {
00245 // ACE_OS_TRACE ("operator <");
00246 return tv2 > tv1;
00247 }
|
|
||||||||||||
|
True if tv1 <= tv2.
Definition at line 252 of file Time_Value.inl.
00254 {
00255 // ACE_OS_TRACE ("operator <=");
00256 return tv2 >= tv1;
00257 }
|
|
||||||||||||
|
True if tv1 == tv2.
Definition at line 262 of file Time_Value.inl.
|
|
||||||||||||
|
True if tv1 > tv2.
Definition at line 181 of file Time_Value.inl.
|
|
||||||||||||
|
True if tv1 >= tv2.
Definition at line 197 of file Time_Value.inl.
|
|
|
Initial value: ACE_INT64_LITERAL (0x19db1ded53e8000)
Definition at line 85 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 <select> 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. Referenced by ACE_Message_Block::ACE_Message_Block, ACE_Message_Queue< ACE_SYNCH_USE >::dequeue_deadline_i, ACE_Activation_Queue::enqueue, ACE_OutputCDR::grow_and_adjust, ACE_Message_Block::init, ACE_Message_Block::msg_deadline_time, ACE_Process_Manager::reap, ACE_Timer_Wheel_T::remove_first, ACE_Process_Manager::wait, and ACE_Process::wait. |
|
|
Store the values as a timeval.
Definition at line 321 of file Time_Value.h. Referenced by msec, normalize, operator const timeval *, operator FILETIME, operator timespec_t, operator timeval, sec, set, and usec. |
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002