*Backed out changeset 3be01fb200a5

--HG--
branch : trunk
This commit is contained in:
maximius
2009-10-17 15:51:44 -07:00
parent 26b5e033ff
commit e585187b24
2257 changed files with 103863 additions and 761 deletions
+69
View File
@@ -1,8 +1,11 @@
// -*- C++ -*-
//
// $Id: Time_Value.inl 82610 2008-08-12 19:46:36Z parsons $
#include "ace/Truncate.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
#if defined (ACE_WIN32) && defined (_WIN32_WCE)
// Something is a bit brain-damaged here and I'm not sure what... this code
// compiled before the OS reorg for ACE 5.4. Since then it hasn't - eVC
@@ -12,7 +15,9 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// - Steve Huston, 23-Aug-2004
extern "C++" {
#endif
// Returns the value of the object as a timeval.
ACE_INLINE
ACE_Time_Value::operator timeval () const
{
@@ -27,20 +32,24 @@ ACE_Time_Value::operator timeval () const
return this->tv_;
#endif /* ACE_HAS_TIME_T_LONG_MISMATCH */
}
ACE_INLINE void
ACE_Time_Value::set (const timeval &tv)
{
// ACE_OS_TRACE ("ACE_Time_Value::set");
this->tv_.tv_sec = tv.tv_sec;
this->tv_.tv_usec = tv.tv_usec;
this->normalize ();
}
ACE_INLINE
ACE_Time_Value::ACE_Time_Value (const struct timeval &tv)
{
// ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value");
this->set (tv);
}
ACE_INLINE
ACE_Time_Value::operator const timeval * () const
{
@@ -55,6 +64,7 @@ ACE_Time_Value::operator const timeval * () const
return (const timeval *) &this->tv_;
#endif /* ACE_HAS_TIME_T_LONG_MISMATCH */
}
ACE_INLINE void
ACE_Time_Value::set (time_t sec, suseconds_t usec)
{
@@ -69,6 +79,7 @@ ACE_Time_Value::set (time_t sec, suseconds_t usec)
#endif
this->normalize ();
}
ACE_INLINE void
ACE_Time_Value::set (double d)
{
@@ -78,16 +89,20 @@ ACE_Time_Value::set (double d)
this->tv_.tv_usec = (suseconds_t) ((d - (double) l) * ACE_ONE_SECOND_IN_USECS + .5);
this->normalize ();
}
// 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?!
ACE_INLINE void
ACE_Time_Value::set (const timespec_t &tv)
{
// ACE_OS_TRACE ("ACE_Time_Value::set");
this->set (tv.tv_sec,
tv.tv_nsec / 1000); // Convert nanoseconds into microseconds.
}
ACE_INLINE
ACE_Time_Value::ACE_Time_Value (void)
// : tv_ ()
@@ -95,37 +110,46 @@ ACE_Time_Value::ACE_Time_Value (void)
// ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value");
this->set (0, 0);
}
ACE_INLINE
ACE_Time_Value::ACE_Time_Value (time_t sec, suseconds_t usec)
{
// ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value");
this->set (sec, usec);
}
// Returns number of seconds.
ACE_INLINE time_t
ACE_Time_Value::sec (void) const
{
// ACE_OS_TRACE ("ACE_Time_Value::sec");
return this->tv_.tv_sec;
}
// Sets the number of seconds.
ACE_INLINE void
ACE_Time_Value::sec (time_t sec)
{
// ACE_OS_TRACE ("ACE_Time_Value::sec");
this->tv_.tv_sec = ACE_Utils::truncate_cast<long> (sec);
}
// Converts from Time_Value format into milli-seconds format.
ACE_INLINE unsigned long
ACE_Time_Value::msec (void) const
{
// ACE_OS_TRACE ("ACE_Time_Value::msec");
// Note - we're truncating a value here, which can lose data. This is
// called out in the user documentation for this with a recommendation to
// use msec(ACE_UINT64&) instead, so just go ahead and truncate.
time_t secs = this->tv_.tv_sec * 1000 + this->tv_.tv_usec / 1000;
return ACE_Utils::truncate_cast<unsigned long> (secs);
}
ACE_INLINE void
ACE_Time_Value::msec (ACE_UINT64 &ms) const
{
@@ -134,6 +158,7 @@ ACE_Time_Value::msec (ACE_UINT64 &ms) const
ms *= 1000;
ms += (this->tv_.tv_usec / 1000);
}
ACE_INLINE void
ACE_Time_Value::msec (ACE_UINT64 &ms) /*const*/
{
@@ -141,7 +166,9 @@ ACE_Time_Value::msec (ACE_UINT64 &ms) /*const*/
const ACE_Time_Value *tv = this;
tv->msec (ms);
}
// Converts from milli-seconds format into Time_Value format.
ACE_INLINE void
ACE_Time_Value::msec (long milliseconds)
{
@@ -152,30 +179,38 @@ ACE_Time_Value::msec (long milliseconds)
// Convert remainder to microseconds;
this->tv_.tv_usec = (milliseconds - (secs * 1000)) * 1000;
}
// Converts from milli-seconds format into Time_Value format.
ACE_INLINE void
ACE_Time_Value::msec (int milliseconds)
{
ACE_Time_Value::msec (static_cast<long> (milliseconds));
}
// Returns number of micro-seconds.
ACE_INLINE suseconds_t
ACE_Time_Value::usec (void) const
{
// ACE_OS_TRACE ("ACE_Time_Value::usec");
return this->tv_.tv_usec;
}
// Sets the number of micro-seconds.
ACE_INLINE void
ACE_Time_Value::usec (suseconds_t usec)
{
// ACE_OS_TRACE ("ACE_Time_Value::usec");
this->tv_.tv_usec = usec;
}
ACE_INLINE void
ACE_Time_Value::to_usec (ACE_UINT64 & usec) const
{
// ACE_OS_TRACE ("ACE_Time_Value::to_usec");
#if defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
usec = ACE_U_LongLong (static_cast<long long> (this->tv_.tv_sec));
#elif defined (ACE_LACKS_LONGLONG_T)
@@ -187,17 +222,21 @@ ACE_Time_Value::to_usec (ACE_UINT64 & usec) const
usec *= 1000000;
usec += this->tv_.tv_usec;
}
ACE_INLINE ACE_Time_Value
operator * (double d, const ACE_Time_Value &tv)
{
return ACE_Time_Value (tv) *= d;
}
ACE_INLINE ACE_Time_Value
operator * (const ACE_Time_Value &tv, double d)
{
return ACE_Time_Value (tv) *= d;
}
// True if tv1 > tv2.
ACE_INLINE bool
operator > (const ACE_Time_Value &tv1,
const ACE_Time_Value &tv2)
@@ -211,7 +250,9 @@ operator > (const ACE_Time_Value &tv1,
else
return 0;
}
// True if tv1 >= tv2.
ACE_INLINE bool
operator >= (const ACE_Time_Value &tv1,
const ACE_Time_Value &tv2)
@@ -225,7 +266,9 @@ operator >= (const ACE_Time_Value &tv1,
else
return 0;
}
// Returns the value of the object as a timespec_t.
ACE_INLINE
ACE_Time_Value::operator timespec_t () const
{
@@ -236,7 +279,9 @@ ACE_Time_Value::operator timespec_t () const
tv.tv_nsec = this->tv_.tv_usec * 1000;
return tv;
}
// Initializes the ACE_Time_Value object from a timespec_t.
ACE_INLINE
ACE_Time_Value::ACE_Time_Value (const timespec_t &tv)
// : tv_ ()
@@ -244,7 +289,9 @@ ACE_Time_Value::ACE_Time_Value (const timespec_t &tv)
// ACE_OS_TRACE ("ACE_Time_Value::ACE_Time_Value");
this->set (tv);
}
// True if tv1 < tv2.
ACE_INLINE bool
operator < (const ACE_Time_Value &tv1,
const ACE_Time_Value &tv2)
@@ -252,7 +299,9 @@ operator < (const ACE_Time_Value &tv1,
// ACE_OS_TRACE ("operator <");
return tv2 > tv1;
}
// True if tv1 >= tv2.
ACE_INLINE bool
operator <= (const ACE_Time_Value &tv1,
const ACE_Time_Value &tv2)
@@ -260,7 +309,9 @@ operator <= (const ACE_Time_Value &tv1,
// ACE_OS_TRACE ("operator <=");
return tv2 >= tv1;
}
// True if tv1 == tv2.
ACE_INLINE bool
operator == (const ACE_Time_Value &tv1,
const ACE_Time_Value &tv2)
@@ -269,7 +320,9 @@ operator == (const ACE_Time_Value &tv1,
return tv1.sec () == tv2.sec ()
&& tv1.usec () == tv2.usec ();
}
// True if tv1 != tv2.
ACE_INLINE bool
operator != (const ACE_Time_Value &tv1,
const ACE_Time_Value &tv2)
@@ -277,7 +330,9 @@ operator != (const ACE_Time_Value &tv1,
// ACE_OS_TRACE ("operator !=");
return !(tv1 == tv2);
}
// Add TV to this.
ACE_INLINE ACE_Time_Value &
ACE_Time_Value::operator+= (const ACE_Time_Value &tv)
{
@@ -287,6 +342,7 @@ ACE_Time_Value::operator+= (const ACE_Time_Value &tv)
this->normalize ();
return *this;
}
ACE_INLINE ACE_Time_Value &
ACE_Time_Value::operator+= (time_t tv)
{
@@ -294,6 +350,7 @@ ACE_Time_Value::operator+= (time_t tv)
this->sec (this->sec () + tv);
return *this;
}
ACE_INLINE ACE_Time_Value &
ACE_Time_Value::operator= (const ACE_Time_Value &tv)
{
@@ -302,6 +359,7 @@ ACE_Time_Value::operator= (const ACE_Time_Value &tv)
this->usec (tv.usec ());
return *this;
}
ACE_INLINE ACE_Time_Value &
ACE_Time_Value::operator= (time_t tv)
{
@@ -310,7 +368,9 @@ ACE_Time_Value::operator= (time_t tv)
this->usec (0);
return *this;
}
// Subtract TV to this.
ACE_INLINE ACE_Time_Value &
ACE_Time_Value::operator-= (const ACE_Time_Value &tv)
{
@@ -320,6 +380,7 @@ ACE_Time_Value::operator-= (const ACE_Time_Value &tv)
this->normalize ();
return *this;
}
ACE_INLINE ACE_Time_Value &
ACE_Time_Value::operator-= (time_t tv)
{
@@ -327,7 +388,9 @@ ACE_Time_Value::operator-= (time_t tv)
this->sec (this->sec () - tv);
return *this;
}
// Adds two ACE_Time_Value objects together, returns the sum.
ACE_INLINE ACE_Time_Value
operator + (const ACE_Time_Value &tv1,
const ACE_Time_Value &tv2)
@@ -335,9 +398,12 @@ operator + (const ACE_Time_Value &tv1,
// ACE_OS_TRACE ("operator +");
ACE_Time_Value sum (tv1);
sum += tv2;
return sum;
}
// Subtracts two ACE_Time_Value objects, returns the difference.
ACE_INLINE ACE_Time_Value
operator - (const ACE_Time_Value &tv1,
const ACE_Time_Value &tv2)
@@ -345,9 +411,12 @@ operator - (const ACE_Time_Value &tv1,
// ACE_OS_TRACE ("operator -");
ACE_Time_Value delta (tv1);
delta -= tv2;
return delta;
}
#if defined (ACE_WIN32) && defined (_WIN32_WCE)
}
#endif
ACE_END_VERSIONED_NAMESPACE_DECL