ACE_Time_Value Class Reference

Operations on "timeval" structures, which express time in seconds (secs) and microseconds (usecs). More...

#include <Time_Value.h>

Collaboration diagram for ACE_Time_Value:

Collaboration graph
[legend]
List of all members.

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_Valueoperator+= (const ACE_Time_Value &tv)
 Add tv to this.

ACE_Time_Valueoperator+= (time_t tv)
 Add tv to this.

ACE_Time_Valueoperator= (const ACE_Time_Value &tv)
 Assign @ tv to this.

ACE_Time_Valueoperator= (time_t tv)
 Assign @ tv to this.

ACE_Time_Valueoperator-= (const ACE_Time_Value &tv)
 Subtract tv to this.

ACE_Time_Valueoperator-= (time_t tv)
 Substract tv to this.

ACE_Time_Valueoperator *= (double d)
 Multiply the time value by the d factor.

ACE_Time_Value operator++ (int)
 Increment microseconds as postfix.

ACE_Time_Valueoperator++ (void)
 Increment microseconds as prefix.

ACE_Time_Value operator-- (int)
 Decrement microseconds as postfix.

ACE_Time_Valueoperator-- (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.


Detailed Description

Operations on "timeval" structures, which express time in seconds (secs) and microseconds (usecs).

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.


Constructor & Destructor Documentation

ACE_INLINE ACE_Time_Value::ACE_Time_Value void   ) 
 

Default Constructor.

Definition at line 102 of file Time_Value.inl.

References set().

00103      : tv_ ()
00104 {
00105   // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value");
00106   this->set (0, 0);
00107 }

ACE_INLINE ACE_Time_Value::ACE_Time_Value time_t  sec,
suseconds_t  usec = 0
[explicit]
 

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 }

ACE_INLINE ACE_Time_Value::ACE_Time_Value const struct timeval &  t  )  [explicit]
 

Construct the ACE_Time_Value from a timeval.

Definition at line 37 of file Time_Value.inl.

References set().

00038      : tv_ ()
00039 {
00040   // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value");
00041   this->set (tv);
00042 }

ACE_INLINE ACE_Time_Value::ACE_Time_Value const timespec_t t  )  [explicit]
 

Construct the ACE_Time_Value object from a timespec_t.

Definition at line 267 of file Time_Value.inl.

References set(), and timespec_t.

00268      : tv_ ()
00269 {
00270   // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value");
00271   this->set (tv);
00272 }

ACE_Time_Value::ACE_Time_Value const FILETIME &  ft  )  [explicit]
 

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 }


Member Function Documentation

void ACE_Time_Value::dump void   )  const
 

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 ACE_Log_Msg is at a higher level.

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 }

ACE_INLINE void ACE_Time_Value::msec long   ) 
 

Converts from milli-seconds format into ACE_Time_Value format.

Note:
The semantics of this method differs from the sec() and usec() methods. There is no analogous "millisecond" component in an ACE_Time_Value.

Definition at line 169 of file Time_Value.inl.

References tv_.

00170 {
00171   // ACE_OS_TRACE ("ACE_Time_Value::msec");
00172   // Convert millisecond units to seconds;
00173   this->tv_.tv_sec = milliseconds / 1000;
00174   // Convert remainder to microseconds;
00175   this->tv_.tv_usec = (milliseconds - (this->tv_.tv_sec * 1000)) * 1000;
00176 }

ACE_INLINE void ACE_Time_Value::msec ACE_UINT64 ms  )  const
 

Returns:
Sum of second field (in milliseconds) and microsecond field (in milliseconds) and return them via the
Parameters:
ms parameter.
Note:
The semantics of this method differs from the sec() and usec() methods. There is no analogous "millisecond" component in an ACE_Time_Value.

Definition at line 157 of file Time_Value.inl.

References ACE_UINT64, and tv_.

00158 {
00159   // ACE_OS_TRACE ("ACE_Time_Value::msec");
00160   ms = static_cast<ACE_UINT64> (this->tv_.tv_sec);
00161   ms *= 1000;
00162   ms += (this->tv_.tv_usec / 1000);
00163 }

ACE_INLINE unsigned long ACE_Time_Value::msec void   )  const
 

Converts from ACE_Time_Value format into milli-seconds format.

Returns:
Sum of second field (in milliseconds) and microsecond field (in milliseconds). Note that this method can overflow if the second and microsecond field values are large, so use the msec (ACE_UINT64 &ms) method instead.
Note:
The semantics of this method differs from the sec() and usec() methods. There is no analogous "millisecond" component in an ACE_Time_Value.

Definition at line 149 of file Time_Value.inl.

References tv_.

Referenced by ACE_High_Res_Timer::calibrate(), ACE_TLI_Connector::complete(), ACE_SPIPE_Connector::connect(), ACE_OS::event_timedwait(), ACE_Timer_Hash_T< TYPE, FUNCTOR, ACE_LOCK, BUCKET >::expire(), 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_Timer_Hash_T< TYPE, FUNCTOR, ACE_LOCK, BUCKET >::reschedule(), ACE_XtReactor::reset_timeout(), ACE_TkReactor::reset_timeout(), ACE_QtReactor::reset_timeout(), ACE_Timer_Hash_T< TYPE, FUNCTOR, ACE_LOCK, BUCKET >::schedule_i(), ACE_OS::sema_wait(), ACE_OS::sleep(), ACE_NT_Service::state(), ACE_Process_Manager::wait(), and ACE_Process::wait().

00150 {
00151   // ACE_OS_TRACE ("ACE_Time_Value::msec");
00152   return this->tv_.tv_sec * 1000 + this->tv_.tv_usec / 1000;
00153 }

void ACE_Time_Value::normalize void   )  [private]
 

Put the timevalue into a canonical form.

Todo:
This loop needs some optimization.

This loop needs some optimization.

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 }

ACE_Time_Value & ACE_Time_Value::operator *= double  d  ) 
 

Multiply the time value by the d factor.

Note:
The result of the operator is valid for results from range < (ACE_INT32_MIN, -999999), (ACE_INT32_MAX, 999999) >. Result outside this range are saturated to a limit.

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 }

ACE_INLINE ACE_Time_Value::operator const timeval *  )  const
 

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 }

ACE_Time_Value::operator FILETIME  )  const
 

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 }

ACE_INLINE ACE_Time_Value::operator timespec_t  )  const
 

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 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_Time_Value::operator timeval  )  const
 

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 }

ACE_Time_Value & ACE_Time_Value::operator++ void   ) 
 

Increment microseconds as prefix.

Note:
The only reason this is here is to allow the use of ACE_Atomic_Op with ACE_Time_Value.

Definition at line 61 of file Time_Value.cpp.

References normalize(), and usec().

00062 {
00063   // ACE_OS_TRACE ("ACE_Time_Value::operator ++ (void)");
00064   this->usec (this->usec () + 1);
00065   this->normalize ();
00066   return *this;
00067 }

ACE_Time_Value ACE_Time_Value::operator++ int   ) 
 

Increment microseconds as postfix.

Note:
The only reason this is here is to allow the use of ACE_Atomic_Op with ACE_Time_Value.

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 }

ACE_INLINE ACE_Time_Value & ACE_Time_Value::operator+= time_t  tv  ) 
 

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 }

ACE_INLINE ACE_Time_Value & ACE_Time_Value::operator+= const ACE_Time_Value tv  ) 
 

Add tv to this.

Definition at line 318 of file Time_Value.inl.

References normalize(), sec(), and usec().

00319 {
00320   // ACE_OS_TRACE ("ACE_Time_Value::operator+=");
00321   this->sec (this->sec () + tv.sec ());
00322   this->usec (this->usec () + tv.usec ());
00323   this->normalize ();
00324   return *this;
00325 }

ACE_Time_Value & ACE_Time_Value::operator-- void   ) 
 

Decrement microseconds as prefix.

Note:
The only reason this is here is to allow the use of ACE_Atomic_Op with ACE_Time_Value.

Definition at line 82 of file Time_Value.cpp.

References normalize(), and usec().

00083 {
00084   // ACE_OS_TRACE ("ACE_Time_Value::operator -- (void)");
00085   this->usec (this->usec () - 1);
00086   this->normalize ();
00087   return *this;
00088 }

ACE_Time_Value ACE_Time_Value::operator-- int   ) 
 

Decrement microseconds as postfix.

Note:
The only reason this is here is to allow the use of ACE_Atomic_Op with ACE_Time_Value.

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 }

ACE_INLINE ACE_Time_Value & ACE_Time_Value::operator-= time_t  tv  ) 
 

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 }

ACE_INLINE ACE_Time_Value & ACE_Time_Value::operator-= const ACE_Time_Value tv  ) 
 

Subtract tv to this.

Definition at line 356 of file Time_Value.inl.

References normalize(), sec(), and usec().

00357 {
00358   // ACE_OS_TRACE ("ACE_Time_Value::operator-=");
00359   this->sec (this->sec () - tv.sec ());
00360   this->usec (this->usec () - tv.usec ());
00361   this->normalize ();
00362   return *this;
00363 }

ACE_INLINE ACE_Time_Value & ACE_Time_Value::operator= time_t  tv  ) 
 

Assign @ tv to this.

Definition at line 345 of file Time_Value.inl.

References sec(), and usec().

00346 {
00347   // ACE_OS_TRACE ("ACE_Time_Value::operator=");
00348   this->sec (tv);
00349   this->usec (0);
00350   return *this;
00351 }

ACE_INLINE ACE_Time_Value & ACE_Time_Value::operator= const ACE_Time_Value tv  ) 
 

Assign @ tv to this.

Definition at line 336 of file Time_Value.inl.

References sec(), and usec().

00337 {
00338   // ACE_OS_TRACE ("ACE_Time_Value::operator=");
00339   this->sec (tv.sec ());
00340   this->usec (tv.usec ());
00341   return *this;
00342 }

ACE_INLINE void ACE_Time_Value::sec time_t  sec  ) 
 

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 }

ACE_INLINE time_t ACE_Time_Value::sec void   )  const
 

Get seconds.

Returns:
The second field/component of this ACE_Time_Value.
Note:
The semantics of this method differs from the msec() method.

Definition at line 119 of file Time_Value.inl.

References tv_.

Referenced by ACE_Name_Request::ACE_Name_Request(), ACE_Time_Request::ACE_Time_Request(), ACE_TLI_Connector::connect(), ACE_Log_Record::decode(), ACE_Time_Request::dump(), ACE_Name_Request::dump(), ACE_Dynamic_Message_Strategy::dump(), ACE_Profile_Timer::elapsed_time(), ACE_OS::event_timedwait(), ACE_System_Time::get_master_system_time(), ACE_OS::gethrtime(), ACE_High_Res_Timer::gettime(), ACE::handle_timed_accept(), ACE::handle_timed_open(), ACE_High_Res_Timer::hrtime_to_tv(), ACE_OS::mktime(), ACE_OS::mutex_lock(), operator *=(), operator timespec_t(), operator+=(), operator-=(), operator<<(), operator=(), operator==(), operator>(), operator>=(), ACE_Timeprobe_Ex< ACE_LOCK, ALLOCATOR >::print_absolute_times(), ACE_Dynamic_Message_Strategy::priority_status(), ACE_Timer_Hash_T< TYPE, FUNCTOR, ACE_LOCK, BUCKET >::reschedule(), ACE_FlReactor::reset_timeout(), ACE_Timer_Hash_T< TYPE, FUNCTOR, ACE_LOCK, BUCKET >::schedule_i(), ACE_OS::sema_wait(), ACE_Token::shared_acquire(), ACE_SOCK_SEQPACK_Connector::shared_connect_finish(), ACE_SOCK_Connector::shared_connect_finish(), ACE_OS::time(), ACE_Log_Record::time_stamp(), ACE_Time_Request::timeout(), ACE_Name_Request::timeout(), ACE::timestamp(), ACE_OS::ualarm(), and ACE_FlReactor::wait_for_multiple_events().

00120 {
00121   // ACE_OS_TRACE ("ACE_Time_Value::sec");
00122   return this->tv_.tv_sec;
00123 }

void ACE_Time_Value::set const FILETIME &  ft  ) 
 

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 }

ACE_INLINE void ACE_Time_Value::set const timespec_t t  ) 
 

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.

00094 {
00095   // ACE_OS_TRACE ("ACE_Time_Value::set");
00096 
00097   this->set (tv.tv_sec,
00098              tv.tv_nsec / 1000); // Convert nanoseconds into microseconds.
00099 }

ACE_INLINE void ACE_Time_Value::set const timeval &  t  ) 
 

Initializes the ACE_Time_Value from a timeval.

Definition at line 27 of file Time_Value.inl.

References normalize(), and tv_.

00028 {
00029   // ACE_OS_TRACE ("ACE_Time_Value::set");
00030   this->tv_.tv_sec = tv.tv_sec;
00031   this->tv_.tv_usec = tv.tv_usec;
00032 
00033   this->normalize ();
00034 }

ACE_INLINE void ACE_Time_Value::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.

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 }

ACE_INLINE void ACE_Time_Value::set time_t  sec,
suseconds_t  usec
 

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 }

ACE_INLINE void ACE_Time_Value::to_usec ACE_UINT64 usec  )  const
 

Returns:
Sum of second field (in microseconds) and microsecond field and return them via the
Parameters:
usec parameter.

Definition at line 198 of file Time_Value.inl.

References ACE_UINT64, and tv_.

Referenced by ACE_Utils::UUID_Generator::get_systemtime().

00199 {
00200   // ACE_OS_TRACE ("ACE_Time_Value::to_usec");
00201   usec = static_cast<ACE_UINT64> (this->tv_.tv_sec);
00202   usec *= 1000000;
00203   usec += this->tv_.tv_usec;
00204 }

ACE_INLINE void ACE_Time_Value::usec suseconds_t  usec  ) 
 

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 }

ACE_INLINE suseconds_t ACE_Time_Value::usec void   )  const
 

Get microseconds.

Returns:
The microsecond field/component of this ACE_Time_Value.
Note:
The semantics of this method differs from the msec() method.

Definition at line 181 of file Time_Value.inl.

References tv_.

Referenced by ACE_Name_Request::ACE_Name_Request(), ACE_Time_Request::ACE_Time_Request(), ACE_TLI_Connector::connect(), ACE_Log_Record::decode(), ACE_Token_Request::dump(), ACE_Time_Request::dump(), ACE_Buffered_Svc_Handler<, >::dump(), ACE_Name_Request::dump(), ACE_Dynamic_Message_Strategy::dump(), ACE_Profile_Timer::elapsed_time(), ACE_WFMO_Reactor::event_handling(), ACE_OS::event_timedwait(), ACE_OS::gethrtime(), ACE_High_Res_Timer::gettime(), ACE::handle_timed_accept(), ACE::handle_timed_open(), ACE_High_Res_Timer::hrtime_to_tv(), ACE_OS::mutex_lock(), operator *=(), operator++(), operator+=(), operator--(), operator-=(), operator<<(), operator=(), operator==(), operator>(), operator>=(), ACE_Timeprobe_Ex< ACE_LOCK, ALLOCATOR >::print_absolute_times(), ACE_Dynamic_Message_Strategy::priority_status(), ACE_Metrics_Cache< ACE_LOCK, ALLOCATOR >::report_dequeue_start(), ACE_Metrics_Cache< ACE_LOCK, ALLOCATOR >::report_enqueue_start(), ACE_FlReactor::reset_timeout(), ACE_Reactor::run_reactor_event_loop(), ACE_OS::sema_wait(), ACE_Token::shared_acquire(), ACE_SOCK_SEQPACK_Connector::shared_connect_finish(), ACE_SOCK_Connector::shared_connect_finish(), ACE_Log_Record::time_stamp(), ACE_Time_Request::timeout(), ACE_Name_Request::timeout(), ACE::timestamp(), ACE_OS::ualarm(), and ACE_FlReactor::wait_for_multiple_events().

00182 {
00183   // ACE_OS_TRACE ("ACE_Time_Value::usec");
00184   return this->tv_.tv_usec;
00185 }


Friends And Related Function Documentation

ACE_Export ACE_Time_Value operator * const ACE_Time_Value tv,
double  d
[friend]
 

Multiplies the time value by d.

Definition at line 214 of file Time_Value.inl.

00215 {
00216   return ACE_Time_Value (tv) *= d;
00217 }

ACE_Export ACE_Time_Value operator * double  d,
const ACE_Time_Value tv
[friend]
 

Multiplies the time value by d.

Definition at line 208 of file Time_Value.inl.

00209 {
00210   return ACE_Time_Value (tv) *= d;
00211 }

ACE_Export bool operator!= const ACE_Time_Value tv1,
const ACE_Time_Value tv2
[friend]
 

True if tv1 != tv2.

Definition at line 308 of file Time_Value.inl.

00310 {
00311   // ACE_OS_TRACE ("operator !=");
00312   return !(tv1 == tv2);
00313 }

ACE_Export ACE_Time_Value operator+ const ACE_Time_Value tv1,
const ACE_Time_Value tv2
[friend]
 

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 }

ACE_Export ACE_Time_Value operator- const ACE_Time_Value tv1,
const ACE_Time_Value tv2
[friend]
 

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 }

ACE_Export bool operator< const ACE_Time_Value tv1,
const ACE_Time_Value tv2
[friend]
 

True if tv1 < tv2.

Definition at line 277 of file Time_Value.inl.

00279 {
00280   // ACE_OS_TRACE ("operator <");
00281   return tv2 > tv1;
00282 }

ACE_Export bool operator<= const ACE_Time_Value tv1,
const ACE_Time_Value tv2
[friend]
 

True if tv1 <= tv2.

Definition at line 287 of file Time_Value.inl.

00289 {
00290   // ACE_OS_TRACE ("operator <=");
00291   return tv2 >= tv1;
00292 }

ACE_Export bool operator== const ACE_Time_Value tv1,
const ACE_Time_Value tv2
[friend]
 

True if tv1 == tv2.

Definition at line 297 of file Time_Value.inl.

00299 {
00300   // ACE_OS_TRACE ("operator ==");
00301   return tv1.sec () == tv2.sec ()
00302     && tv1.usec () == tv2.usec ();
00303 }

ACE_Export bool operator> const ACE_Time_Value tv1,
const ACE_Time_Value tv2
[friend]
 

True if tv1 > tv2.

Definition at line 222 of file Time_Value.inl.

00224 {
00225   // ACE_OS_TRACE ("operator >");
00226   if (tv1.sec () > tv2.sec ())
00227     return 1;
00228   else if (tv1.sec () == tv2.sec ()
00229            && tv1.usec () > tv2.usec ())
00230     return 1;
00231   else
00232     return 0;
00233 }

ACE_Export bool operator>= const ACE_Time_Value tv1,
const ACE_Time_Value tv2
[friend]
 

True if tv1 >= tv2.

Definition at line 238 of file Time_Value.inl.

00240 {
00241   // ACE_OS_TRACE ("operator >=");
00242   if (tv1.sec () > tv2.sec ())
00243     return 1;
00244   else if (tv1.sec () == tv2.sec ()
00245            && tv1.usec () >= tv2.usec ())
00246     return 1;
00247   else
00248     return 0;
00249 }


Member Data Documentation

const DWORDLONG ACE_Time_Value::FILETIME_to_timval_skew [static]
 

Initial value:

ACE_INT64_LITERAL (0x19db1ded53e8000)
Const time difference between FILETIME and POSIX time.

Definition at line 102 of file Time_Value.cpp.

Referenced by operator FILETIME(), and set().

const ACE_Time_Value ACE_Time_Value::max_time [static]
 

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.

timeval ACE_Time_Value::tv_ [private]
 

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().

ACE_BEGIN_VERSIONED_NAMESPACE_DECL const ACE_Time_Value ACE_Time_Value::zero [static]
 

Constant "0".

Definition at line 28 of file Time_Value.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:31:10 2006 for ACE by doxygen 1.3.6