This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Resolved status.

786. Thread library timed waits, UTC and monotonic clocks

Section: 29 [time] Status: Resolved Submitter: Christopher Kohlhoff, Jeff Garland Opened: 2008-02-03 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [time].

View all issues with Resolved status.

Discussion:

The draft C++0x thread library requires that the time points of type system_time and returned by get_system_time() represent Coordinated Universal Time (UTC) (section [datetime.system]). This can lead to surprising behavior when a library user performs a duration-based wait, such as condition_variable::timed_wait(). A complete explanation of the problem may be found in the Rationale for the Monotonic Clock section in POSIX, but in summary:

POSIX solves the problem by introducing a new monotonic clock, which is unaffected by changes to the system time. When a condition variable is initialized, the user may specify whether the monotonic clock is to be used. (It is worth noting that on POSIX systems it is not possible to use condition_variable::native_handle() to access this facility, since the desired clock type must be specified during construction of the condition variable object.)

In the context of the C++0x thread library, there are added dimensions to the problem due to the need to support platforms other than POSIX:

One possible minimal solution:

Proposed resolution:

Rationale:

Addressed by N2661: A Foundation to Sleep On.