Dan Albert 5e37d7f9ff Implement std::condition_variable via pthread_cond_clockwait() where available
std::condition_variable is currently implemented via
pthread_cond_timedwait() on systems that use pthread. This is
problematic, since that function waits by default on CLOCK_REALTIME
and libc++ does not provide any mechanism to change from this
default.

Due to this, regardless of if condition_variable::wait_until() is
called with a chrono::system_clock or chrono::steady_clock parameter,
condition_variable::wait_until() will wait using CLOCK_REALTIME. This
is not accurate to the C++ standard as calling
condition_variable::wait_until() with a chrono::steady_clock parameter
should use CLOCK_MONOTONIC.

This is particularly problematic because CLOCK_REALTIME is a bad
choice as it is subject to discontinuous time adjustments, that may
cause condition_variable::wait_until() to immediately timeout or wait
indefinitely.

This change fixes this issue with a new POSIX function,
pthread_cond_clockwait() proposed on
http://austingroupbugs.net/view.php?id=1216. The new function is
similar to pthread_cond_timedwait() with the addition of a clock
parameter that allows it to wait using either CLOCK_REALTIME or
CLOCK_MONOTONIC, thus allowing condition_variable::wait_until() to
wait using CLOCK_REALTIME for chrono::system_clock and CLOCK_MONOTONIC
for chrono::steady_clock.

pthread_cond_clockwait() is implemented in glibc (2.30 and later) and
Android's bionic (Android API version 30 and later).

This change additionally makes wait_for() and wait_until() with clocks
other than chrono::system_clock use CLOCK_MONOTONIC.<Paste>

llvm-svn: 372016
2019-09-16 17:57:48 +00:00
..
2019-08-20 10:19:55 +00:00
2019-08-12 07:51:05 +00:00
2019-07-11 23:13:38 +00:00
2019-06-13 22:27:24 +00:00
2019-09-07 22:18:20 +00:00
2019-08-12 07:51:05 +00:00
2019-06-21 15:20:55 +00:00
ios
2019-05-29 16:01:36 +00:00
2019-08-20 18:21:06 +00:00
2019-07-01 16:13:31 +00:00
2019-05-29 16:01:36 +00:00
2019-05-29 16:01:36 +00:00
2019-08-12 18:30:31 +00:00
2019-09-13 20:30:45 +00:00
2019-05-29 02:38:19 +00:00
2019-07-14 21:29:39 +00:00