This is an archive of the discontinued LLVM Phabricator instance.

Implement the standard for timeouts for std::condition_variable
AbandonedPublic

Authored by tomcherry on Aug 15 2017, 2:12 PM.

Details

Summary

The C++ standard calls for wait_for() to use steady clock and
wait_until() to use the clock that is provided as an argument. This
is not currently done in libc++ and is not possible with the pthreads
API, however it is possible with the underlying futex system call.

This change re-implements std::condition_variable with a tweaked
version of the implementation of pthread_cond_* from Android bionic to
support the correct semantics.

Bug: 35756266

Event Timeline

tomcherry created this revision.Aug 15 2017, 2:12 PM

This is mostly an RFC. The underlying issue is that we cannot use timed waits based on CLOCK_REALTIME on Android. In trying to fix that, I figured I might as well try implementing the standard as described, though I understand that there'd be resistance to such a re-implementation.