[PATCH 1/2] condition_variable: Report early wakeup of wait_until as no_timeout

Jonathan Wakely jwakely@redhat.com
Fri Jul 20 11:44:00 GMT 2018


On 20/07/18 12:30 +0100, Mike Crowe wrote:
>On Friday 20 July 2018 at 11:53:38 +0100, Jonathan Wakely wrote:
>> On 10/07/18 11:09 +0100, Mike Crowe wrote:
>> > As currently implemented, condition_variable always ultimately waits
>> > against std::chrono::system_clock. This clock can be changed in arbitrary
>> > ways by the user which may result in us waking up too early or too late
>> > when measured against the caller-supplied clock.
>> >
>> > We can't (yet) do much about waking up too late[1], but
>> > if we wake up too early we must return cv_status::no_timeout to indicate a
>> > spurious wakeup rather than incorrectly returning cv_status::timeout.
>>
>> The patch looks good, thanks.
>>
>> Can we come up with a test for this, using a user-defined clock that
>> jumps back?
>
>That's a good idea. I'll do that.

Thanks.

There are "broken" clocks in testsuite/30_threads/this_thread/60421.cc
and testsuite/30_threads/timed_mutex/try_lock_until/57641.cc but I'm
not sure if either of them is reusable. A custom one for this test
should be reasonably easy.



More information about the Libstdc++ mailing list