786. Thread library timed waits, UTC and monotonic clocks

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

Priority: Not Prioritized

View all other issues in [time].

View all issues with Resolved status.


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:


Addressed by N2661: A Foundation to Sleep On.