ACE  6.3.3
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
ACE_Time_Value Class Reference

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

#include <Time_Value_T.h>

Inheritance diagram for ACE_Time_Value:
Inheritance graph
[legend]
Collaboration diagram for ACE_Time_Value:
Collaboration graph
[legend]

Public Member Functions

 ACE_Time_Value (void)
 Default Constructor. More...
 
 ACE_Time_Value (time_t sec, suseconds_t usec=0)
 Constructor. More...
 
 ACE_Time_Value (const struct timeval &t)
 Construct the ACE_Time_Value from a timeval. More...
 
 ACE_Time_Value (const timespec_t &t)
 Construct the ACE_Time_Value object from a timespec_t. More...
 
virtual ~ACE_Time_Value ()
 Destructor. More...
 
 ACE_Time_Value (const FILETIME &ft)
 Construct the ACE_Time_Value object from a Win32 FILETIME. More...
 
void set (time_t sec, suseconds_t usec)
 Initializes the ACE_Time_Value from seconds and useconds. More...
 
void set (double d)
 
void set (const timeval &t)
 Initializes the ACE_Time_Value from a timeval. More...
 
void set (const timespec_t &t)
 Initializes the ACE_Time_Value object from a timespec_t. More...
 
void set (const FILETIME &ft)
 Initializes the ACE_Time_Value object from a Win32 FILETIME. More...
 
unsigned long msec (void) const
 Converts from ACE_Time_Value format into milliseconds format. More...
 
ACE_UINT64 get_msec () const
 Converts from ACE_Time_Value format into milliseconds format. More...
 
void msec (ACE_UINT64 &ms) const
 Converts from ACE_Time_Value format into milliseconds format. More...
 
void msec (ACE_UINT64 &ms)
 Converts from ACE_Time_Value format into milliseconds format. More...
 
void set_msec (const ACE_UINT64 &ms)
 Converts from milli-seconds format into ACE_Time_Value format. More...
 
void msec (long)
 Converts from milli-seconds format into ACE_Time_Value format. More...
 
void msec (int)
 Converts from milli-seconds format into ACE_Time_Value format. More...
 
 operator timespec_t () const
 Returns the value of the object as a timespec_t. More...
 
 operator timeval () const
 Returns the value of the object as a timeval. More...
 
 operator const timeval * () const
 Returns a pointer to the object as a timeval. More...
 
 operator FILETIME () const
 Returns the value of the object as a Win32 FILETIME. More...
 
time_t sec (void) const
 Get seconds. More...
 
void sec (time_t sec)
 Set seconds. More...
 
suseconds_t usec (void) const
 Get microseconds. More...
 
void usec (suseconds_t usec)
 Set microseconds. More...
 
void to_usec (ACE_UINT64 &usec) const
 
ACE_Time_Valueoperator+= (const ACE_Time_Value &tv)
 Add tv to this. More...
 
ACE_Time_Valueoperator+= (time_t tv)
 Add tv to this. More...
 
ACE_Time_Valueoperator= (const ACE_Time_Value &tv)
 Assign tv to this. More...
 
ACE_Time_Valueoperator= (time_t tv)
 Assign tv to this. More...
 
ACE_Time_Valueoperator-= (const ACE_Time_Value &tv)
 Subtract tv to this. More...
 
ACE_Time_Valueoperator-= (time_t tv)
 Subtract tv to this. More...
 
ACE_Time_Valueoperator*= (double d)
 Multiply the time value by the d factor. More...
 
ACE_Time_Value operator++ (int)
 Increment microseconds as postfix. More...
 
ACE_Time_Valueoperator++ (void)
 Increment microseconds as prefix. More...
 
ACE_Time_Value operator-- (int)
 Decrement microseconds as postfix. More...
 
ACE_Time_Valueoperator-- (void)
 Decrement microseconds as prefix. More...
 
virtual ACE_Time_Value now () const
 Get current time of day. More...
 
virtual ACE_Time_Value to_relative_time () const
 Converts absolute time value to time value relative to current time of day. More...
 
virtual ACE_Time_Value to_absolute_time () const
 Converts relative time value to absolute time value based on current time of day. More...
 
virtual ACE_Time_Valueduplicate () const
 Duplicates this time value (incl. time policy). More...
 
void dump (void) const
 Dump is a no-op. More...
 

Static Public Attributes

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

Private Member Functions

void normalize (bool saturate=false)
 Put the timevalue into a canonical form. More...
 

Private Attributes

timeval tv_
 Store the values as a timeval. More...
 

Friends

ACE_Time_Value operator+ (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2)
 Adds two ACE_Time_Value objects together, returns the sum. More...
 
ACE_Time_Value operator- (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2)
 Subtracts two ACE_Time_Value objects, returns the difference. More...
 
bool operator< (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2)
 True if tv1 < tv2. More...
 
bool operator> (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2)
 True if tv1 > tv2. More...
 
bool operator<= (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2)
 True if tv1 <= tv2. More...
 
bool operator>= (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2)
 True if tv1 >= tv2. More...
 
bool operator== (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2)
 True if tv1 == tv2. More...
 
bool operator!= (const ACE_Time_Value &tv1, const ACE_Time_Value &tv2)
 True if tv1 != tv2. More...
 
ACE_Time_Value operator* (double d, const ACE_Time_Value &tv)
 Multiplies the time value by d. More...
 
ACE_Time_Value operator* (const ACE_Time_Value &tv, double d)
 Multiplies the time value by d. More...
 

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

Constructor & Destructor Documentation

ACE_Time_Value::ACE_Time_Value ( void  )
inline

Default Constructor.

ACE_Time_Value::ACE_Time_Value ( time_t  sec,
suseconds_t  usec = 0 
)
inlineexplicit

Constructor.

ACE_Time_Value::ACE_Time_Value ( const struct timeval &  t)
inlineexplicit

Construct the ACE_Time_Value from a timeval.

ACE_Time_Value::ACE_Time_Value ( const timespec_t t)
inlineexplicit

Construct the ACE_Time_Value object from a timespec_t.

Initializes the ACE_Time_Value object from a timespec_t.

ACE_Time_Value::~ACE_Time_Value ( )
virtual

Destructor.

ACE_Time_Value::ACE_Time_Value ( const FILETIME &  ft)
explicit

Construct the ACE_Time_Value object from a Win32 FILETIME.

Initializes 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.

ACE_Time_Value * ACE_Time_Value::duplicate ( void  ) const
virtual

Duplicates this time value (incl. time policy).

Returns
Dynamically allocated time value copy.
Note
The caller is responsible for freeing the copy when it's not needed anymore.

Reimplemented in ACE_Time_Value_T< TIME_POLICY >.

ACE_UINT64 ACE_Time_Value::get_msec ( ) const
inline

Converts from ACE_Time_Value format into milliseconds format.

Returns
Sum of second field (in milliseconds) and microsecond field (in milliseconds).
Note
The semantics of this method differs from the sec() and usec() methods. There is no analogous "millisecond" component in an ACE_Time_Value.
unsigned long ACE_Time_Value::msec ( void  ) const
inline

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.
void ACE_Time_Value::msec ( ACE_UINT64 ms) const
inline

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
msparameter.
Note
The semantics of this method differs from the sec() and usec() methods. There is no analogous "millisecond" component in an ACE_Time_Value.
Deprecated:
Use get_msec() instead.
void ACE_Time_Value::msec ( ACE_UINT64 ms)
inline

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
msparameter.
Note
The semantics of this method differs from the sec() and usec() methods. There is no analogous "millisecond" component in an ACE_Time_Value.
Deprecated:
Use get_msec() instead.
void ACE_Time_Value::msec ( long  milliseconds)
inline

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.
void ACE_Time_Value::msec ( int  milliseconds)
inline

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.
void ACE_Time_Value::normalize ( bool  saturate = false)
private

Put the timevalue into a canonical form.

Todo:
This loop needs some optimization.
Todo:
This loop needs some optimization.
ACE_Time_Value ACE_Time_Value::now ( ) const
virtual

Get current time of day.

Returns
Time value representing current time of day.
Note
This method is overloaded in the time policy based template instantiations derived from this class. Allows for time policy aware time values.

Reimplemented in ACE_Time_Value_T< TIME_POLICY >.

ACE_Time_Value::operator const timeval * ( ) const
inline

Returns a pointer to the object as a timeval.

ACE_Time_Value::operator FILETIME ( ) const

Returns the value of the object as a Win32 FILETIME.

ACE_Time_Value::operator timespec_t ( ) const
inline

Returns the value of the object as a timespec_t.

ACE_Time_Value::operator timeval ( ) const
inline

Returns the value of the object as a timeval.

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

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.
ACE_Time_Value & ACE_Time_Value::operator+= ( const ACE_Time_Value tv)
inline

Add tv to this.

Add TV to this.

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

Add tv to this.

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

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.
ACE_Time_Value & ACE_Time_Value::operator-= ( const ACE_Time_Value tv)
inline

Subtract tv to this.

Subtract TV to this.

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

Subtract tv to this.

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

Assign tv to this.

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

Assign tv to this.

time_t ACE_Time_Value::sec ( void  ) const
inline

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.
void ACE_Time_Value::sec ( time_t  sec)
inline

Set seconds.

Sets the number of seconds.

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

Initializes the ACE_Time_Value from seconds and useconds.

void ACE_Time_Value::set ( double  d)
inline

Initializes the ACE_Time_Value from a double, which is assumed to be in second format, with any remainder treated as microseconds.

void ACE_Time_Value::set ( const timeval &  t)
inline

Initializes the ACE_Time_Value from a timeval.

void ACE_Time_Value::set ( const timespec_t tv)
inline

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?!

void ACE_Time_Value::set ( const FILETIME &  ft)

Initializes the ACE_Time_Value object from a Win32 FILETIME.

void ACE_Time_Value::set_msec ( const ACE_UINT64 ms)
inline

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.
ACE_Time_Value ACE_Time_Value::to_absolute_time ( ) const
virtual

Converts relative time value to absolute time value based on current time of day.

Returns
Absolute time value.
Note
This method is overloaded in the time policy based template instantiations derived from this class. Allows for time policy aware time values. The developer is responsible for making sure this is a relative time value. Current time of day is determined based on time policy (which is system time for the base class).

Reimplemented in ACE_Time_Value_T< TIME_POLICY >.

ACE_Time_Value ACE_Time_Value::to_relative_time ( ) const
virtual

Converts absolute time value to time value relative to current time of day.

Returns
Relative time value.
Note
This method is overloaded in the time policy based template instantiations derived from this class. Allows for time policy aware time values. The developer is responsible for making sure this is an absolute time value compatible with the active time policy (which is system time for the base class).

Reimplemented in ACE_Time_Value_T< TIME_POLICY >.

void ACE_Time_Value::to_usec ( ACE_UINT64 usec) const
inline
Returns
Sum of second field (in microseconds) and microsecond field and return them via the
Parameters
usecparameter.
suseconds_t ACE_Time_Value::usec ( void  ) const
inline

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.
void ACE_Time_Value::usec ( suseconds_t  usec)
inline

Set microseconds.

Sets the number of micro-seconds.

Friends And Related Function Documentation

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

True if tv1 != tv2.

ACE_Time_Value operator* ( double  d,
const ACE_Time_Value tv 
)
friend

Multiplies the time value by d.

ACE_Time_Value operator* ( const ACE_Time_Value tv,
double  d 
)
friend

Multiplies the time value by d.

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_Time_Value operator- ( const ACE_Time_Value tv1,
const ACE_Time_Value tv2 
)
friend

Subtracts two ACE_Time_Value objects, returns the difference.

bool operator< ( const ACE_Time_Value tv1,
const ACE_Time_Value tv2 
)
friend

True if tv1 < tv2.

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

True if tv1 <= tv2.

bool operator== ( const ACE_Time_Value tv1,
const ACE_Time_Value tv2 
)
friend

True if tv1 == tv2.

bool operator> ( const ACE_Time_Value tv1,
const ACE_Time_Value tv2 
)
friend

True if tv1 > tv2.

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

True if tv1 >= tv2.

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.

Static constant to remove time skew between FILETIME and POSIX time. POSIX and Win32 use different epochs (Jan. 1, 1970 v.s. Jan. 1, 1601). The following constant defines the difference in 100ns ticks.

In the beginning (Jan. 1, 1601), there was no time and no computer. And Bill said: "Let there be time," and there was time....

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

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. Note: this object requires static construction.

timeval ACE_Time_Value::tv_
private

Store the values as a timeval.

const ACE_Time_Value ACE_Time_Value::zero
static

Constant "0".

Static constant representing `zero-time'. Note: this object requires static construction.


The documentation for this class was generated from the following files: