class Duration

Defined at line 165 of file ../../third_party/abseil-cpp/absl/time/time.h

Duration

The `absl::Duration` class represents a signed, fixed-length amount of time.

A `Duration` is generated using a unit-specific factory function, or is

the result of subtracting one `absl::Time` from another. Durations behave

like unit-safe integers and they support all the natural integer-like

arithmetic operations. Arithmetic overflows and saturates at +/- infinity.

`Duration` should be passed by value rather than const reference.

Factory functions `Nanoseconds()`, `Microseconds()`, `Milliseconds()`,

`Seconds()`, `Minutes()`, `Hours()` and `InfiniteDuration()` allow for

creation of constexpr `Duration` values

Examples:

constexpr absl::Duration ten_ns = absl::Nanoseconds(10);

constexpr absl::Duration min = absl::Minutes(1);

constexpr absl::Duration hour = absl::Hours(1);

absl::Duration dur = 60 * min; // dur == hour

absl::Duration half_sec = absl::Milliseconds(500);

absl::Duration quarter_sec = 0.25 * absl::Seconds(1);

`Duration` values can be easily converted to an integral number of units

using the division operator.

Example:

constexpr absl::Duration dur = absl::Milliseconds(1500);

int64_t ns = dur / absl::Nanoseconds(1); // ns == 1500000000

int64_t ms = dur / absl::Milliseconds(1); // ms == 1500

int64_t sec = dur / absl::Seconds(1); // sec == 1 (subseconds truncated)

int64_t min = dur / absl::Minutes(1); // min == 0

See the `IDivDuration()` and `FDivDuration()` functions below for details on

how to access the fractional parts of the quotient.

Alternatively, conversions can be performed using helpers such as

`ToInt64Microseconds()` and `ToDoubleSeconds()`.

Public Methods

void Duration ()

Value semantics.

Defined at line 168 of file ../../third_party/abseil-cpp/absl/time/time.h

void Duration (const Duration & d)

Defined at line 176 of file ../../third_party/abseil-cpp/absl/time/time.h

Duration & operator+= (Duration d)

Compound assignment operators.

Duration & operator-= (Duration d)
Duration & operator*= (int64_t r)
Duration & operator*= (double r)
Duration & operator/= (int64_t r)
Duration & operator/= (double r)
Duration & operator%= (Duration rhs)
Duration & operator= (const Duration & d)

Defined at line 178 of file ../../third_party/abseil-cpp/absl/time/time.h

template <typename T, time_internal::EnableIfIntegral<T> = 0>
Duration & operator*= (T r)

Overloads that forward to either the int64_t or double overloads above.

Integer operands must be representable as int64_t. Integer division is

truncating, so values less than the resolution will be returned as zero.

Floating-point multiplication and division is rounding (halfway cases

rounding away from zero), so values less than the resolution may be

returned as either the resolution or zero. In particular, `d / 2.0`

can produce `d` when it is the resolution and "even".

Defined at line 197 of file ../../third_party/abseil-cpp/absl/time/time.h

template <typename T, time_internal::EnableIfIntegral<T> = 0>
Duration & operator/= (T r)

Defined at line 203 of file ../../third_party/abseil-cpp/absl/time/time.h

template <typename T, time_internal::EnableIfFloat<T> = 0>
Duration & operator*= (T r)

Defined at line 209 of file ../../third_party/abseil-cpp/absl/time/time.h

template <typename T, time_internal::EnableIfFloat<T> = 0>
Duration & operator/= (T r)

Defined at line 215 of file ../../third_party/abseil-cpp/absl/time/time.h

Friends

Duration Duration (int64_t hi, uint32_t lo)
uint32_t Duration (Duration d)
int64_t Duration (Duration d)
template <typename H>
H Duration (H hDuration d)