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 milliseconds format.
void msec (ACE_UINT64 &ms) const
 Converts from ACE_Time_Value format into milliseconds format.
void msec (ACE_UINT64 &ms)
 Converts from ACE_Time_Value format into milliseconds format.
void msec (long)
 Converts from milli-seconds format into ACE_Time_Value format.
void msec (int)
 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

static const ACE_Time_Value zero
 Constant "0".
static const ACE_Time_Value max_time
static const ACE_U_LongLong FILETIME_to_timval_skew
 Const time difference between FILETIME and POSIX time.
static const DWORDLONG FILETIME_to_timval_skew

Private Member Functions

void normalize (void)
 Put the timevalue into a canonical form.

Private Attributes

struct {
   time_t   tv_sec
   suseconds_t   tv_usec
tv_
 Store the values as a timeval.
timeval ext_tv_
timeval tv_

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 <select>, <poll>, or <cond_timedwait>.

Definition at line 57 of file Time_Value.h.


Constructor & Destructor Documentation

ACE_Time_Value::ACE_Time_Value ( void   ) 

Default Constructor.

Definition at line 107 of file Time_Value.inl.

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

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

Constructor.

Definition at line 115 of file Time_Value.inl.

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

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

Construct the ACE_Time_Value from a timeval.

Definition at line 36 of file Time_Value.inl.

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

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

Construct the ACE_Time_Value object from a timespec_t.

Initializes the ACE_Time_Value object from a timespec_t.

Definition at line 275 of file Time_Value.inl.

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

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

Construct the ACE_Time_Value object from a Win32 FILETIME.


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

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

void ACE_Time_Value::msec ( int  milliseconds  ) 

Converts from milli-seconds format into ACE_Time_Value format.

Converts from milli-seconds format into 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 181 of file Time_Value.inl.

00182 {
00183   ACE_Time_Value::msec (static_cast<long> (milliseconds));
00184 }

void ACE_Time_Value::msec ( long  milliseconds  ) 

Converts from milli-seconds format into ACE_Time_Value format.

Converts from milli-seconds format into 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.

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

void ACE_Time_Value::msec ( ACE_UINT64 ms  ) 

Converts from ACE_Time_Value format into milliseconds format.

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

00161 {
00162   // ACE_OS_TRACE ("ACE_Time_Value::msec");
00163   const ACE_Time_Value *tv = this;
00164   tv->msec (ms);
00165 }

void ACE_Time_Value::msec ( ACE_UINT64 ms  )  const

Converts from ACE_Time_Value format into milliseconds format.

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

00152 {
00153   // ACE_OS_TRACE ("ACE_Time_Value::msec");
00154   ms = ACE_Utils::truncate_cast<ACE_UINT64> (this->tv_.tv_sec);
00155   ms *= 1000;
00156   ms += (this->tv_.tv_usec / 1000);
00157 }

unsigned long ACE_Time_Value::msec ( void   )  const

Converts from ACE_Time_Value format into milliseconds format.

Converts from 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 139 of file Time_Value.inl.

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

void ACE_Time_Value::normalize ( void   )  [private]

Put the timevalue into a canonical form.

Todo:
This loop needs some optimization.
Todo:
This loop needs some optimization.

Definition at line 165 of file Time_Value.cpp.

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

ACE_Time_Value::operator const timeval * (  )  const

Returns a pointer to the object as a timeval.

Definition at line 43 of file Time_Value.inl.

00044 {
00045   // ACE_OS_TRACE ("ACE_Time_Value::operator const timeval *");
00046 #if defined (ACE_HAS_TIME_T_LONG_MISMATCH)
00047   // Recall that on some Windows we substitute another type for timeval in tv_
00048   ACE_Time_Value *me = const_cast<ACE_Time_Value*> (this);
00049   me->ext_tv_.tv_sec = ACE_Utils::truncate_cast<long> (this->tv_.tv_sec);
00050   me->ext_tv_.tv_usec = ACE_Utils::truncate_cast<long> (this->tv_.tv_usec);
00051   return (const timeval *) &this->ext_tv_;
00052 #else
00053   return (const timeval *) &this->tv_;
00054 #endif /* ACE_HAS_TIME_T_LONG_MISMATCH */
00055 }

ACE_Time_Value::operator FILETIME (  )  const

Returns the value of the object as a Win32 FILETIME.

ACE_Time_Value::operator timespec_t (  )  const

Returns the value of the object as a timespec_t.

Definition at line 263 of file Time_Value.inl.

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

ACE_Time_Value::operator timeval (  )  const

Returns the value of the object as a timeval.

Definition at line 11 of file Time_Value.inl.

00012 {
00013   // ACE_OS_TRACE ("ACE_Time_Value::operator timeval");
00014 #if defined (ACE_HAS_TIME_T_LONG_MISMATCH)
00015   // Recall that on some Windows we substitute another type for timeval in tv_
00016   ACE_Time_Value *me = const_cast<ACE_Time_Value*> (this);
00017   me->ext_tv_.tv_sec = ACE_Utils::truncate_cast<long> (this->tv_.tv_sec);
00018   me->ext_tv_.tv_usec = ACE_Utils::truncate_cast<long> (this->tv_.tv_usec);
00019   return this->ext_tv_;
00020 #else
00021   return this->tv_;
00022 #endif /* ACE_HAS_TIME_T_LONG_MISMATCH */
00023 }

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

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

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

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

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.

Increment microseconds (the only reason this is here is to allow the use of ACE_Atomic_Op with ACE_Time_Value).

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 }

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

Add tv to this.

Definition at line 331 of file Time_Value.inl.

00332 {
00333   // ACE_OS_TRACE ("ACE_Time_Value::operator+=");
00334   this->sec (this->sec () + tv);
00335   return *this;
00336 }

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

Add tv to this.

Add TV to this.

Definition at line 321 of file Time_Value.inl.

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

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

00065 {
00066   // ACE_OS_TRACE ("ACE_Time_Value::operator -- (void)");
00067   this->usec (this->usec () - 1);
00068   this->normalize ();
00069   return *this;
00070 }

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.

Decrement microseconds (the only reason this is here is / to allow the use of ACE_Atomic_Op with ACE_Time_Value).

Definition at line 55 of file Time_Value.cpp.

00056 {
00057   // ACE_OS_TRACE ("ACE_Time_Value::operator -- (int)");
00058   ACE_Time_Value tv (*this);
00059   --*this;
00060   return tv;
00061 }

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

Substract tv to this.

Definition at line 368 of file Time_Value.inl.

00369 {
00370   // ACE_OS_TRACE ("ACE_Time_Value::operator-=");
00371   this->sec (this->sec () - tv);
00372   return *this;
00373 }

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

Subtract tv to this.

Subtract TV to this.

Definition at line 358 of file Time_Value.inl.

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

ACE_Time_Value & ACE_Time_Value::operator= ( time_t  tv  ) 

Assign @ tv to this.

Definition at line 348 of file Time_Value.inl.

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

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

Assign @ tv to this.

Definition at line 339 of file Time_Value.inl.

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

void ACE_Time_Value::sec ( time_t  sec  ) 

Set seconds.

Sets the number of seconds.

Definition at line 131 of file Time_Value.inl.

00132 {
00133   // ACE_OS_TRACE ("ACE_Time_Value::sec");
00134   this->tv_.tv_sec = ACE_Utils::truncate_cast<long> (sec);
00135 }

time_t ACE_Time_Value::sec ( void   )  const

Get seconds.

Returns number of 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 123 of file Time_Value.inl.

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

void ACE_Time_Value::set ( const FILETIME &  ft  ) 

Initializes the ACE_Time_Value object from a Win32 FILETIME.

void ACE_Time_Value::set ( const timespec_t tv  ) 

Initializes the ACE_Time_Value object from a timespec_t.

Initializes a timespec_t. Note that this approach loses precision since it converts the nano-seconds into micro-seconds. But then again, do any real systems have nano-second timer precision?!

Definition at line 98 of file Time_Value.inl.

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

void ACE_Time_Value::set ( const timeval &  t  ) 

Initializes the ACE_Time_Value from a timeval.

Definition at line 26 of file Time_Value.inl.

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

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.

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 }

void ACE_Time_Value::set ( time_t  sec,
suseconds_t  usec 
)

Initializes the ACE_Time_Value from seconds and useconds.

Definition at line 58 of file Time_Value.inl.

00059 {
00060   // ACE_OS_TRACE ("ACE_Time_Value::set");
00061 # if defined (_WIN32_WCE) && (_WIN32_WCE == 0x600) && !defined (_USE_32BIT_TIME_T) && defined (_MSC_VER)
00062     // The WinCE 6.0 SDK ships with a timeval tv_sec member that uses long as type
00063     // not time_t. This resolves in compilation warnings because time_t
00064     // can be 64bit. Disable at this momemt the warning for just this method
00065     // else we get a compile warnings each time this inline file is included
00066     // this file.
00067 #   pragma warning (push)
00068 #   pragma warning (disable: 4244)
00069 # endif
00070   this->tv_.tv_sec = sec;
00071 # if defined (_WIN32_WCE) && (_WIN32_WCE == 0x600) && !defined (_USE_32BIT_TIME_T) && defined (_MSC_VER)
00072 #   pragma warning (pop)
00073 # endif
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 }

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

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

void ACE_Time_Value::usec ( suseconds_t  usec  ) 

Set microseconds.

Sets the number of micro-seconds.

Definition at line 196 of file Time_Value.inl.

00197 {
00198   // ACE_OS_TRACE ("ACE_Time_Value::usec");
00199   this->tv_.tv_usec = usec;
00200 }

suseconds_t ACE_Time_Value::usec ( void   )  const

Get microseconds.

Returns number of micro-seconds.

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

Definition at line 188 of file Time_Value.inl.

00189 {
00190   // ACE_OS_TRACE ("ACE_Time_Value::usec");
00191   return this->tv_.tv_usec;
00192 }


Friends And Related Function Documentation

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

True if tv1 != tv2.

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

Multiplies the time value by d.

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

Multiplies the time value by d.

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.

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.

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

True if tv1 < tv2.

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

True if tv1 <= tv2.

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

True if tv1 == tv2.

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

True if tv1 > tv2.

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

True if tv1 >= tv2.


Member Data Documentation

timeval ACE_Time_Value::ext_tv_ [private]

Definition at line 343 of file Time_Value.h.

const DWORDLONG ACE_Time_Value::FILETIME_to_timval_skew [static]

Definition at line 321 of file Time_Value.h.

Const time difference between FILETIME and POSIX time.

Definition at line 319 of file Time_Value.h.

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.

Definition at line 72 of file Time_Value.h.

timeval ACE_Time_Value::tv_ [private]

Definition at line 345 of file Time_Value.h.

struct { ... } ACE_Time_Value::tv_ [private]

Store the values as a timeval.

Definition at line 340 of file Time_Value.h.

Definition at line 341 of file Time_Value.h.

Constant "0".

Definition at line 62 of file Time_Value.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Sat Nov 21 23:18:55 2009 for ACE by  doxygen 1.6.1