Quick Links:

bal | bbl | bdl | bsl

Namespaces

Component bsls_systemclocktype
[Package bsls]

Enumerate the set of system clock types. More...

Namespaces

namespace  bsls

Detailed Description

Outline
Purpose:
Enumerate the set of system clock types.
Classes:
bsls::SystemClockType namespace for a clock type enum
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:
  bsls::SystemClockType::Enum value = bsls::SystemClockType::e_MONOTONIC;
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);
Finally, we verify the value of asciiValue:
  assert(0 == strcmp(asciiValue, "MONOTONIC"));