Page MenuHomePhabricator

[libcxx] Support waiting on monotonic clock with ext. threading
Needs ReviewPublic

Authored by miyuki on Jan 18 2022, 10:35 AM.


Group Reviewers
Restricted Project

This patch adds support for using the monotonic clock (steady_clock)
when waiting on a condition variable with a timeout. This feature is
currently implemented for POSIX threads. The patch generalizes it to
be usable with an external threading library by adding

The external threading layer implementors should define
_LIBCPP_CONDVAR_HAS_MONOTONIC_TIMEDWAIT in their __external_threading
header and implement the __libcpp_condvar_monotonic_timedwait function
to use the feature.

Diff Detail

Event Timeline

miyuki requested review of this revision.Jan 18 2022, 10:35 AM
miyuki created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2022, 10:35 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
miyuki updated this revision to Diff 400911.Jan 18 2022, 10:39 AM

Added missing "_LIBCPP_HIDE_FROM_ABI inline"

miyuki updated this revision to Diff 400913.Jan 18 2022, 10:48 AM

No comment from me; this is above my pay grade. :)
But I could bikeshed the name of the macro: The old name reflected the pthreads name, pthread_cond_clockwait -> _LIBCPP_HAS_COND_CLOCKWAIT. The new name reflects nothing we didn't make up ourselves; so maybe it should be more like _LIBCPP_HAS_MONOTONIC_TIMEDWAIT or _LIBCPP_CONDVAR_HAS_MONOTONIC_TIMEDWAIT. My understanding is that "steady" is a WG21-ism for "monotonic": even though you named the new function __libcpp_condvar_steady_timedwait, we never actually use steady_clock anywhere in its signature or implementation. Instead it depends on pthreads' CLOCK_MONOTONIC.

miyuki updated this revision to Diff 401643.Jan 20 2022, 8:00 AM
miyuki retitled this revision from [libcxx] Support waiting on steady clock with ext. threading to [libcxx] Support waiting on monotonic clock with ext. threading.
miyuki edited the summary of this revision. (Show Details)

Renamed steady -> monotonic.

@ldionne, could you please have a look at this patch?