BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsls_systemclocktype

Detailed Description

Outline

Purpose

Enumerate the set of system clock types.

Classes

Description

This component provides a namespace for the enum type bsls::SystemClockType::Enum, which enumerates the set of system clock types. A bsls::SystemClockType is particularly important when providing time-out values to synchronization methods where those time-outs must be consistent in environments where the system clocks may be changed.

Enumerators

Name Description
----------- -------------------------------------------------------------
e_REALTIME System clock that returns the current wall time maintained by
the system, and which is affected by adjustments to the
system's clock (i.e., time values returned may jump
"forwards" and "backwards" as the current time-of-day is
changed on the system).
e_MONOTONIC System clock that returns the elapsed time since some
unspecified starting point in the past. The returned values
are monotonically non-decreasing, and are generally not
affected by changes to the system time.

Usage

This section illustrates intended use of this component.

Example 1: Basic Syntax

The following snippets of code provide a simple illustration of using bsls::SystemClockType.

First, we create a variable value of type bsls::SystemClockType::Enum and initialize it with the enumerator value bsls::SystemClockType::e_MONOTONIC:

Enum
Definition bsls_systemclocktype.h:117
@ e_MONOTONIC
Definition bsls_systemclocktype.h:126

Now, we store the address of its ASCII representation in a pointer variable, asciiValue, of type const char *:

const char *asciiValue = bsls::SystemClockType::toAscii(value);
static const char * toAscii(SystemClockType::Enum value)

Finally, we verify the value of asciiValue:

assert(0 == strcmp(asciiValue, "MONOTONIC"));