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 108 of file Time_Value.inl.

References set().

00109      : tv_ ()
00110 {
00111   // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value");
00112   this->set (0, 0);
00113 }

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

Constructor.

Definition at line 116 of file Time_Value.inl.

References set().

00117 {
00118   // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value");
00119   this->set (sec, usec);
00120 }

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

Construct the ACE_Time_Value from a timeval.

Definition at line 47 of file Time_Value.inl.

References set().

00048      : tv_ ()
00049 {
00050   // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value");
00051   this->set (tv);
00052 }

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 273 of file Time_Value.inl.

References set(), and timespec_t.

00274      : tv_ ()
00275 {
00276   // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value");
00277   this->set (tv);
00278 }

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

Construct the ACE_Time_Value object from a Win32 FILETIME.

Definition at line 93 of file Time_Value.cpp.

References set().

00094 {
00095   // // ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value");
00096   this->set (file_time);
00097 }


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 156 of file Time_Value.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_TEXT, and LM_DEBUG.

Referenced by ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::dump(), and ACE_Timer_Node_T< TYPE >::dump().

00157 {
00158 #if defined (ACE_HAS_DUMP)
00159   // ACE_OS_TRACE ("ACE_Time_Value::dump");
00160 #if 0
00161   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00162   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntv_sec_ = %d"), this->tv_.tv_sec));
00163   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntv_usec_ = %d\n"), this->tv_.tv_usec));
00164   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00165 #endif /* 0 */
00166 #endif /* ACE_HAS_DUMP */
00167 }

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 168 of file Time_Value.inl.

References tv_.

00169 {
00170   // ACE_OS_TRACE ("ACE_Time_Value::msec");
00171   // Convert millisecond units to seconds;
00172   long secs = milliseconds / 1000;
00173   this->tv_.tv_sec = secs;
00174   // Convert remainder to microseconds;
00175   this->tv_.tv_usec = (milliseconds - (secs * 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 156 of file Time_Value.inl.

References ACE_UINT64, and tv_.

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

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 143 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_OS::mutex_lock(), ACE_OS::poll(), ACE_Timer_Hash_T< TYPE, FUNCTOR, ACE_LOCK, BUCKET >::reschedule(), ACE_Timer_Hash_T< TYPE, FUNCTOR, ACE_LOCK, BUCKET >::schedule_i(), ACE_OS::sema_wait(), ACE_OS::sleep(), ACE_Process_Manager::wait(), and ACE_Process::wait().

00144 {
00145   // ACE_OS_TRACE ("ACE_Time_Value::msec");
00146 
00147   // Note - we're truncating a value here, which can lose data. This is
00148   // called out in the user documentation for this with a recommendation to
00149   // use msec(ACE_UINT64&) instead, so just go ahead and truncate.
00150   time_t secs = this->tv_.tv_sec * 1000 + this->tv_.tv_usec / 1000;
00151   return ACE_Utils::truncate_cast<unsigned long> (secs);
00152 }

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 170 of file Time_Value.cpp.

References ACE_ONE_SECOND_IN_USECS, and tv_.

Referenced by operator++(), operator+=(), operator--(), operator-=(), and set().

00171 {
00172   // // ACE_OS_TRACE ("ACE_Time_Value::normalize");
00173   // From Hans Rohnert...
00174 
00175   if (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS)
00176     {
00177       /*! \todo This loop needs some optimization.
00178        */
00179       do
00180         {
00181           ++this->tv_.tv_sec;
00182           this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS;
00183         }
00184       while (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS);
00185     }
00186   else if (this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS)
00187     {
00188       /*! \todo This loop needs some optimization.
00189        */
00190       do
00191         {
00192           --this->tv_.tv_sec;
00193           this->tv_.tv_usec += ACE_ONE_SECOND_IN_USECS;
00194         }
00195       while (this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS);
00196     }
00197 
00198   if (this->tv_.tv_sec >= 1 && this->tv_.tv_usec < 0)
00199     {
00200       --this->tv_.tv_sec;
00201       this->tv_.tv_usec += ACE_ONE_SECOND_IN_USECS;
00202     }
00203 // tv_sec in qnxnto is unsigned
00204 #if !defined ( __QNXNTO__)
00205   else if (this->tv_.tv_sec < 0 && this->tv_.tv_usec > 0)
00206     {
00207       ++this->tv_.tv_sec;
00208       this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS;
00209     }
00210 #endif /* __QNXNTO__  */
00211 }

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 215 of file Time_Value.cpp.

References ACE_ONE_SECOND_IN_USECS, ACE_Numeric_Limits< T >::max(), ACE_Numeric_Limits< T >::min(), sec(), set(), and usec().

00216 {
00217   // The floating type to be used in the computations.  It should be
00218   // large enough to hold a time_t.  We actually want a floating type
00219   // with enough digits in its mantissa to hold a time_t without
00220   // losing precision.  For example, if FLT_RADIX is 2 and
00221   // LDBL_MANT_DIG is 64, a long double has a 64 bit wide mantissa,
00222   // which would be sufficient to hold a 64 bit time_t value without
00223   // losing precision.
00224   //
00225   // For now we'll simply go with long double if it is larger than
00226   // time_t.  We're hosed if long double isn't large enough.
00227   typedef ACE::If_Then_Else<(sizeof (double) > sizeof (time_t)),
00228                             double,
00229                             long double>::result_type float_type;
00230 
00231   float_type time_total =
00232     (this->sec ()
00233      + static_cast<float_type> (this->usec ()) / ACE_ONE_SECOND_IN_USECS) * d;
00234 
00235   // shall we saturate the result?
00236   static const float_type max_int =
00237     ACE_Numeric_Limits<time_t>::max () + 0.999999;
00238   static const float_type min_int =
00239     ACE_Numeric_Limits<time_t>::min () - 0.999999;
00240 
00241   if (time_total > max_int)
00242     time_total = max_int;
00243   if (time_total < min_int)
00244     time_total = min_int;
00245 
00246   const time_t time_sec = static_cast<time_t> (time_total);
00247 
00248   time_total -= time_sec;
00249   time_total *= ACE_ONE_SECOND_IN_USECS;
00250 
00251   suseconds_t time_usec = static_cast<suseconds_t> (time_total);
00252 
00253   // round up the result to save the last usec
00254   if (time_usec > 0 && (time_total - time_usec) >= 0.5)
00255     ++time_usec;
00256   else if (time_usec < 0 && (time_total - time_usec) <= -0.5)
00257     --time_usec;
00258 
00259   this->set (time_sec, time_usec);
00260 
00261   return *this;
00262 }

ACE_INLINE ACE_Time_Value::operator const timeval *  )  const
 

Returns a pointer to the object as a timeval.

Definition at line 55 of file Time_Value.inl.

References tv_.

00056 {
00057   // ACE_OS_TRACE ("ACE_Time_Value::operator const timeval *");
00058 #if defined (ACE_HAS_TIME_T_LONG_MISMATCH)
00059   // Recall that on some Windows we substitute another type for timeval in tv_
00060   ACE_Time_Value *me = const_cast<ACE_Time_Value*> (this);
00061   me->ext_tv_.tv_sec = ACE_Utils::truncate_cast<long> (this->tv_.tv_sec);
00062   me->ext_tv_.tv_usec = ACE_Utils::truncate_cast<long> (this->tv_.tv_usec);
00063   return (const timeval *) &this->ext_tv_;
00064 #else
00065   return (const timeval *) &this->tv_;
00066 #endif /* ACE_HAS_TIME_T_LONG_MISMATCH */
00067 }

ACE_Time_Value::operator FILETIME  )  const
 

Returns the value of the object as a Win32 FILETIME.

Definition at line 127 of file Time_Value.cpp.

References FILETIME_to_timval_skew, and tv_.

00128 {
00129   FILETIME file_time;
00130   // ACE_OS_TRACE ("ACE_Time_Value::operator FILETIME");
00131 
00132 #if defined (ACE_LACKS_LONGLONG_T)
00133   ACE_U_LongLong LL_sec(this->tv_.tv_sec);
00134   ACE_U_LongLong LL_usec(this->tv_.tv_usec);
00135   ACE_U_LongLong LL_100ns = LL_sec * (ACE_UINT32)(10000 * 1000) +
00136                             LL_usec * (ACE_UINT32)10 +
00137                             ACE_Time_Value::FILETIME_to_timval_skew;
00138   file_time.dwLowDateTime = LL_100ns.lo();
00139   file_time.dwHighDateTime = LL_100ns.hi();
00140 #else
00141   ULARGE_INTEGER _100ns;
00142   _100ns.QuadPart = (((DWORDLONG) this->tv_.tv_sec * (10000 * 1000) +
00143                      this->tv_.tv_usec * 10) +
00144                      ACE_Time_Value::FILETIME_to_timval_skew);
00145 
00146   file_time.dwLowDateTime = _100ns.LowPart;
00147   file_time.dwHighDateTime = _100ns.HighPart;
00148 #endif //ACE_LACKS_LONGLONG_T
00149 
00150   return file_time;
00151 }

ACE_INLINE ACE_Time_Value::operator timespec_t  )  const
 

Returns the value of the object as a timespec_t.

Definition at line 260 of file Time_Value.inl.

References sec(), timespec_t, tv_, timespec::tv_nsec, and timespec::tv_sec.

00261 {
00262   // ACE_OS_TRACE ("ACE_Time_Value::operator timespec_t");
00263   timespec_t tv;
00264   tv.tv_sec = this->sec ();
00265   // Convert microseconds into nanoseconds.
00266   tv.tv_nsec = this->tv_.tv_usec * 1000;
00267   return tv;
00268 }

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 22 of file Time_Value.inl.

References tv_.

00023 {
00024   // ACE_OS_TRACE ("ACE_Time_Value::operator timeval");
00025 #if defined (ACE_HAS_TIME_T_LONG_MISMATCH)
00026   // Recall that on some Windows we substitute another type for timeval in tv_
00027   ACE_Time_Value *me = const_cast<ACE_Time_Value*> (this);
00028   me->ext_tv_.tv_sec = ACE_Utils::truncate_cast<long> (this->tv_.tv_sec);
00029   me->ext_tv_.tv_usec = ACE_Utils::truncate_cast<long> (this->tv_.tv_usec);
00030   return this->ext_tv_;
00031 #else
00032   return this->tv_;
00033 #endif /* ACE_HAS_TIME_T_LONG_MISMATCH */
00034 }

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 46 of file Time_Value.cpp.

References normalize(), and usec().

00047 {
00048   // ACE_OS_TRACE ("ACE_Time_Value::operator ++ (void)");
00049   this->usec (this->usec () + 1);
00050   this->normalize ();
00051   return *this;
00052 }

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 37 of file Time_Value.cpp.

00038 {
00039   // ACE_OS_TRACE ("ACE_Time_Value::operator ++ (int)");
00040   ACE_Time_Value tv (*this);
00041   ++*this;
00042   return tv;
00043 }

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

Add tv to this.

Definition at line 334 of file Time_Value.inl.

References sec().

00335 {
00336   // ACE_OS_TRACE ("ACE_Time_Value::operator+=");
00337   this->sec (this->sec () + tv);
00338   return *this;
00339 }

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

Add tv to this.

Definition at line 324 of file Time_Value.inl.

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

00325 {
00326   // ACE_OS_TRACE ("ACE_Time_Value::operator+=");
00327   this->sec (this->sec () + tv.sec ());
00328   this->usec (this->usec () + tv.usec ());
00329   this->normalize ();
00330   return *this;
00331 }

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 67 of file Time_Value.cpp.

References normalize(), and usec().

00068 {
00069   // ACE_OS_TRACE ("ACE_Time_Value::operator -- (void)");
00070   this->usec (this->usec () - 1);
00071   this->normalize ();
00072   return *this;
00073 }

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 58 of file Time_Value.cpp.

00059 {
00060   // ACE_OS_TRACE ("ACE_Time_Value::operator -- (int)");
00061   ACE_Time_Value tv (*this);
00062   --*this;
00063   return tv;
00064 }

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

Substract tv to this.

Definition at line 372 of file Time_Value.inl.

References sec().

00373 {
00374   // ACE_OS_TRACE ("ACE_Time_Value::operator-=");
00375   this->sec (this->sec () - tv);
00376   return *this;
00377 }

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

Subtract tv to this.

Definition at line 362 of file Time_Value.inl.

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

00363 {
00364   // ACE_OS_TRACE ("ACE_Time_Value::operator-=");
00365   this->sec (this->sec () - tv.sec ());
00366   this->usec (this->usec () - tv.usec ());
00367   this->normalize ();
00368   return *this;
00369 }

ACE_INLINE ACE_Time_Value & ACE_Time_Value::operator= time_t  tv  ) 
 

Assign @ tv to this.

Definition at line 351 of file Time_Value.inl.

References sec(), and usec().

00352 {
00353   // ACE_OS_TRACE ("ACE_Time_Value::operator=");
00354   this->sec (tv);
00355   this->usec (0);
00356   return *this;
00357 }

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

Assign @ tv to this.

Definition at line 342 of file Time_Value.inl.

References sec(), and usec().

00343 {
00344   // ACE_OS_TRACE ("ACE_Time_Value::operator=");
00345   this->sec (tv.sec ());
00346   this->usec (tv.usec ());
00347   return *this;
00348 }

ACE_INLINE void ACE_Time_Value::sec time_t  sec  ) 
 

Set seconds.

Definition at line 134 of file Time_Value.inl.

References tv_.

00135 {
00136   // ACE_OS_TRACE ("ACE_Time_Value::sec");
00137   this->tv_.tv_sec = sec;
00138 }

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 125 of file Time_Value.inl.

References tv_.

Referenced by ACE_Name_Request::ACE_Name_Request(), ACE_TLI_Connector::connect(), ACE_Log_Record::decode(), 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_Dynamic_Message_Strategy::priority_status(), ACE_Timer_Hash_T< TYPE, FUNCTOR, ACE_LOCK, BUCKET >::reschedule(), 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_Name_Request::timeout(), ACE::timestamp(), and ACE_OS::ualarm().

00126 {
00127   // ACE_OS_TRACE ("ACE_Time_Value::sec");
00128   return this->tv_.tv_sec;
00129 }

void ACE_Time_Value::set const FILETIME &  ft  ) 
 

Initializes the ACE_Time_Value object from a Win32 FILETIME.

Definition at line 99 of file Time_Value.cpp.

References FILETIME_to_timval_skew, normalize(), and tv_.

00100 {
00101   //  Initializes the ACE_Time_Value object from a Win32 FILETIME
00102 #if defined (ACE_LACKS_LONGLONG_T)
00103   ACE_U_LongLong LL_100ns(file_time.dwLowDateTime, file_time.dwHighDateTime);
00104   LL_100ns -= ACE_Time_Value::FILETIME_to_timval_skew;
00105   // Convert 100ns units to seconds;
00106   this->tv_.tv_sec = (long) (LL_100ns / ((double) (10000 * 1000)));
00107   // Convert remainder to microseconds;
00108   this->tv_.tv_usec = (suseconds_t)((LL_100ns % ((ACE_UINT32)(10000 * 1000))) / 10);
00109 #else
00110   // Don't use a struct initializer, gcc don't like it.
00111   ULARGE_INTEGER _100ns;
00112   _100ns.LowPart = file_time.dwLowDateTime;
00113   _100ns.HighPart = file_time.dwHighDateTime;
00114 
00115   _100ns.QuadPart -= ACE_Time_Value::FILETIME_to_timval_skew;
00116 
00117   // Convert 100ns units to seconds;
00118   this->tv_.tv_sec = (long) (_100ns.QuadPart / (10000 * 1000));
00119   // Convert remainder to microseconds;
00120   this->tv_.tv_usec = (suseconds_t) ((_100ns.QuadPart % (10000 * 1000)) / 10);
00121 #endif // ACE_LACKS_LONGLONG_T
00122   this->normalize ();
00123 }

ACE_INLINE void ACE_Time_Value::set const timespec_t t  ) 
 

Initializes the ACE_Time_Value object from a timespec_t.

Definition at line 99 of file Time_Value.inl.

References set(), timespec_t, timespec::tv_nsec, and timespec::tv_sec.

00100 {
00101   // ACE_OS_TRACE ("ACE_Time_Value::set");
00102 
00103   this->set (tv.tv_sec,
00104              tv.tv_nsec / 1000); // Convert nanoseconds into microseconds.
00105 }

ACE_INLINE void ACE_Time_Value::set const timeval &  t  ) 
 

Initializes the ACE_Time_Value from a timeval.

Definition at line 37 of file Time_Value.inl.

References normalize(), and tv_.

00038 {
00039   // ACE_OS_TRACE ("ACE_Time_Value::set");
00040   this->tv_.tv_sec = tv.tv_sec;
00041   this->tv_.tv_usec = tv.tv_usec;
00042 
00043   this->normalize ();
00044 }

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 85 of file Time_Value.inl.

References ACE_ONE_SECOND_IN_USECS, normalize(), and tv_.

00086 {
00087   // ACE_OS_TRACE ("ACE_Time_Value::set");
00088   long l = (long) d;
00089   this->tv_.tv_sec = l;
00090   this->tv_.tv_usec = (suseconds_t) ((d - (double) l) * ACE_ONE_SECOND_IN_USECS + .5);
00091   this->normalize ();
00092 }

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 70 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 *=(), and set().

00071 {
00072   // ACE_OS_TRACE ("ACE_Time_Value::set");
00073   this->tv_.tv_sec = sec;
00074   this->tv_.tv_usec = usec;
00075 #if __GNUC__
00076   if (__builtin_constant_p(sec) &&
00077       __builtin_constant_p(usec) &&
00078       (sec >= 0 && usec >= 0 && usec < ACE_ONE_SECOND_IN_USECS))
00079     return;
00080 #endif
00081   this->normalize ();
00082 }

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 197 of file Time_Value.inl.

References ACE_UINT64, and tv_.

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

00198 {
00199   // ACE_OS_TRACE ("ACE_Time_Value::to_usec");
00200 
00201 #if defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
00202   usec = ACE_U_LongLong (static_cast<long long> (this->tv_.tv_sec));
00203 #elif defined (ACE_LACKS_LONGLONG_T)
00204   // No native 64-bit type, meaning time_t is most likely 32 bits.
00205   usec = ACE_U_LongLong (this->tv_.tv_sec);
00206 #else
00207   usec = static_cast<ACE_UINT64> (this->tv_.tv_sec);
00208 #endif  /* ACE_LACKS_LONG_LONG_T */
00209   usec *= 1000000;
00210   usec += this->tv_.tv_usec;
00211 }

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_TLI_Connector::connect(), ACE_Log_Record::decode(), ACE_Buffered_Svc_Handler<, >::dump(), ACE_Name_Request::dump(), ACE_Dynamic_Message_Strategy::dump(), ACE_Profile_Timer::elapsed_time(), 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_Dynamic_Message_Strategy::priority_status(), 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_Name_Request::timeout(), ACE::timestamp(), and ACE_OS::ualarm().

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 220 of file Time_Value.inl.

00221 {
00222   return ACE_Time_Value (tv) *= d;
00223 }

ACE_Export ACE_Time_Value operator * double  d,
const ACE_Time_Value tv
[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 bool operator!= const ACE_Time_Value tv1,
const ACE_Time_Value tv2
[friend]
 

True if tv1 != tv2.

Definition at line 314 of file Time_Value.inl.

00316 {
00317   // ACE_OS_TRACE ("operator !=");
00318   return !(tv1 == tv2);
00319 }

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 382 of file Time_Value.inl.

00384 {
00385   // ACE_OS_TRACE ("operator +");
00386   ACE_Time_Value sum (tv1);
00387   sum += tv2;
00388 
00389   return sum;
00390 }

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 395 of file Time_Value.inl.

00397 {
00398   // ACE_OS_TRACE ("operator -");
00399   ACE_Time_Value delta (tv1);
00400   delta -= tv2;
00401 
00402   return delta;
00403 }

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

True if tv1 < tv2.

Definition at line 283 of file Time_Value.inl.

00285 {
00286   // ACE_OS_TRACE ("operator <");
00287   return tv2 > tv1;
00288 }

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

True if tv1 <= tv2.

Definition at line 293 of file Time_Value.inl.

00295 {
00296   // ACE_OS_TRACE ("operator <=");
00297   return tv2 >= tv1;
00298 }

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

True if tv1 == tv2.

Definition at line 303 of file Time_Value.inl.

00305 {
00306   // ACE_OS_TRACE ("operator ==");
00307   return tv1.sec () == tv2.sec ()
00308     && tv1.usec () == tv2.usec ();
00309 }

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

True if tv1 > tv2.

Definition at line 228 of file Time_Value.inl.

00230 {
00231   // ACE_OS_TRACE ("operator >");
00232   if (tv1.sec () > tv2.sec ())
00233     return 1;
00234   else if (tv1.sec () == tv2.sec ()
00235            && tv1.usec () > tv2.usec ())
00236     return 1;
00237   else
00238     return 0;
00239 }

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

True if tv1 >= tv2.

Definition at line 244 of file Time_Value.inl.

00246 {
00247   // ACE_OS_TRACE ("operator >=");
00248   if (tv1.sec () > tv2.sec ())
00249     return 1;
00250   else if (tv1.sec () == tv2.sec ()
00251            && tv1.usec () >= tv2.usec ())
00252     return 1;
00253   else
00254     return 0;
00255 }


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 87 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 337 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 19 of file Time_Value.cpp.


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 12:58:46 2008 for ACE by doxygen 1.3.6