Clock calls on VxWorks are slow, so the odds that the consecutive
calls of *clock::now() will yield a different result are not
negligible. Reordering the calls avoids false positives.
for libstdc++-v3/ChangeLog
* testsuite/30_threads/semaphore/try_acquire_until.cc
(test01): Reorder calls.
}
{
- auto const at = std::chrono::system_clock::now() + dur;
+ // Set the base time T0 first, so that even if there's a delay before the
+ // deadline AT is computed, it won't shrink the measured DIFF to the point
+ // of making it seem shorter than the required wait DURation.
auto const t0 = std::chrono::steady_clock::now();
+ auto const at = std::chrono::system_clock::now() + dur;
VERIFY( !s.try_acquire_until(at) );
auto const diff = std::chrono::steady_clock::now() - t0;
VERIFY( diff >= dur );