---
name: "ACE_Time_Value"
section: "3"
platform: "linux"
package: "libace-doc"
version: "5.0.7-4"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/ACE_Time_Value"
---

# ACE\_Time\_Value(3)

Operations on "timeval" structures.

## NAME

ACE\_Time\_Value -  Operations on "timeval" structures.

## SYNOPSIS

```
#include <ace/OS.h>
class ACE_Time_Value
{
  public:
    static const ACE_Time_Value zero;
    static const ACE_Time_Value max_time;
    ACE_Time_Value (void);
    ACE_Time_Value (long sec, long usec = 0);
    ACE_Time_Value (const struct timeval &t);
    ACE_Time_Value (const timespec_t &t);
    ACE_Time_Value (const ACE_Time_Value &tv);
    ACE_Time_Value (const FILETIME &ft);
    void set (long sec, long usec);
    void set (double d);
    void set (const timeval &t);
    void set (const timespec_t &t);
    void set (const FILETIME &ft);
    long msec (void) const;
    void msec (long);
    operator timespec_t () const;
    operator timeval () const;
    operator const timeval *() const;
    operator FILETIME () const;
    long sec (void) const;
    void sec (long sec);
    long usec (void) const;
    void usec (long usec);
    void operator += (const ACE_Time_Value &tv);
    void operator -= (const ACE_Time_Value &tv);
    friend ACE_Export ACE_Time_Value operator + (
        const ACE_Time_Value &tv1,
        const ACE_Time_Value &tv2
        );
    friend ACE_Export ACE_Time_Value operator - (
        const ACE_Time_Value &tv1,
        const ACE_Time_Value &tv2
        );
    friend ACE_Export int operator < (
        const ACE_Time_Value &tv1,
        const ACE_Time_Value &tv2
        );
    friend ACE_Export int operator > (
        const ACE_Time_Value &tv1,
        const ACE_Time_Value &tv2
        );
    friend ACE_Export int operator <= (
        const ACE_Time_Value &tv1,
        const ACE_Time_Value &tv2
        );
    friend ACE_Export int operator >= (
        const ACE_Time_Value &tv1,
        const ACE_Time_Value &tv2
        );
    friend ACE_Export int operator == (
        const ACE_Time_Value &tv1,
        const ACE_Time_Value &tv2
        );
    friend ACE_Export int operator != (
        const ACE_Time_Value &tv1,
        const ACE_Time_Value &tv2
        );
    void dump (void) const;
    static const DWORDLONG FILETIME_to_timval_skew;
  private:
    void normalize (void);
    timeval tv_;
};
```

## DESCRIPTION

This class centralizes all the time related processing in ACE.  These timers are typically used in conjunction with OS mechanisms like select, poll, or cond\_timedwait. ACE\_Time\_Value makes the use of these mechanisms portable across OS platforms,

## Useful constants.

```
static const ACE_Time_Value zero;
```

Constant "0".

```
static const ACE_Time_Value max_time;
```

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.

## Initialization methods.

```
ACE_Time_Value (void);
```

Default Constructor.

```
ACE_Time_Value (long sec, long usec = 0);
```

Constructor.

## Methods for converting to/from various time formats.

```
ACE_Time_Value (const struct timeval &t);
```

Construct the ACE\_Time\_Value from a timeval.

```
ACE_Time_Value (const timespec_t &t);
```

Initializes the ACE\_Time\_Value object from a timespec\_t.

```
ACE_Time_Value (const ACE_Time_Value &tv);
```

Copy constructor.

```
ACE_Time_Value (const FILETIME &ft);
```

Initializes the ACE\_Time\_Value object from a Win32 FILETIME

```
void set (long sec, long usec);
```

Construct a Time\_Value from two longs.

```
void set (double d);
```

Construct a Time\_Value from a double, which is assumed to be in second format, with any remainder treated as microseconds.

```
void set (const timeval &t);
```

Construct a Time\_Value from a timeval.

```
void set (const timespec_t &t);
```

Initializes the Time\_Value object from a timespec\_t.

```
void set (const FILETIME &ft);
```

Initializes the Time\_Value object from a timespec\_t.

```
long msec (void) const;
```

Converts from Time\_Value format into milli-seconds format.

```
void msec (long);
```

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

## The following are accessor/mutator methods.

```
long sec (void) const;
```

Get seconds.

```
void sec (long sec);
```

Set seconds.

```
long usec (void) const;
```

Get microseconds.

```
void usec (long usec);
```

Set microseconds.

## The following are arithmetic methods for operating on

Time\_Values.

```
void operator += (const ACE_Time_Value &tv);
```

Add tv to this.

```
void operator -= (const ACE_Time_Value &tv);
```

Subtract tv to this.

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

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

```
friend ACE_Export int operator < (
    const ACE_Time_Value &tv1,
    const ACE_Time_Value &tv2
    );
```

True if tv1  tv2.

```
friend ACE_Export int operator > (
    const ACE_Time_Value &tv1,
    const ACE_Time_Value &tv2
    );
```

True if tv1  tv2.

```
friend ACE_Export int operator <= (
    const ACE_Time_Value &tv1,
    const ACE_Time_Value &tv2
    );
```

True if tv1 = tv2.

```
friend ACE_Export int operator >= (
    const ACE_Time_Value &tv1,
    const ACE_Time_Value &tv2
    );
```

True if tv1 = tv2.

```
friend ACE_Export int operator == (
    const ACE_Time_Value &tv1,
    const ACE_Time_Value &tv2
    );
```

True if tv1 == tv2.

```
friend ACE_Export int operator != (
    const ACE_Time_Value &tv1,
    const ACE_Time_Value &tv2
    );
```

True if tv1 != tv2.

```
void dump (void) const;
```

Dump the state of an object.

```
static const DWORDLONG FILETIME_to_timval_skew;
```

Const time difference between FILETIME and POSIX time.

## AUTHOR

Doug Schmidt schmidt@cs.wustl.edu, Jesper S. M\|ller stophph@diku.dk, and a cast of thousands...

## The ACE\_Sched\_Priority type should be used for platform-

independent thread and process priorities, by convention. int should be used for OS-specific priorities.

## typedef for the \_stat data structure

## Giving unique ACE scoped names for some important

RTSignal-Related constants. Becuase sometimes, different platforms use different names for these constants.

## LIBRARY

ace
