[libcxx-commits] [PATCH] D99175: [libcxx] [test] Make the condvar wait_for tests less brittle

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 1 09:13:08 PDT 2021


Quuxplusone added inline comments.


================
Comment at: libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp:54
+        d = wait_end - Clock::now();
+        if (d <= milliseconds(0)) break;
+    } while (test2 == 0 && cv.wait_for(lk, d) == std::cv_status::no_timeout);
----------------
I instinctively object to code that produces negative durations (e.g. `milliseconds(-1)`).
If you can show me where the standard says `milliseconds(-1)` is definitely supported, then I'll reluctantly relent — but expect me to forget that within a year and be back to my mental model that "you can't have a negative duration." :)
With my current mental model, I'd like to see a fix where we never subtract `x - y` until we've verified that `x >= y`.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99175/new/

https://reviews.llvm.org/D99175



More information about the libcxx-commits mailing list