[libcxx] r273091 - Fix SleepFor(...) helper when a monotonic clock is not available.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 18 11:32:26 PDT 2016


Author: ericwf
Date: Sat Jun 18 13:32:26 2016
New Revision: 273091

URL: http://llvm.org/viewvc/llvm-project?rev=273091&view=rev
Log:
Fix SleepFor(...) helper when a monotonic clock is not available.

Single threaded builds often don't provide a monotonic clock, so we can't
always provide a monotonic SleepFor(...) implementation. Hopefully this
won't cause the builds to hang.

Modified:
    libcxx/trunk/test/support/filesystem_test_helper.hpp

Modified: libcxx/trunk/test/support/filesystem_test_helper.hpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/filesystem_test_helper.hpp?rev=273091&r1=273090&r2=273091&view=diff
==============================================================================
--- libcxx/trunk/test/support/filesystem_test_helper.hpp (original)
+++ libcxx/trunk/test/support/filesystem_test_helper.hpp Sat Jun 18 13:32:26 2016
@@ -388,9 +388,13 @@ inline std::error_code GetTestEC() {
 // available in single-threaded mode.
 void SleepFor(std::chrono::seconds dur) {
     using namespace std::chrono;
-    const auto curr_time = steady_clock::now();
-    auto wake_time = curr_time + dur;
-    while (steady_clock::now() < wake_time)
+#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
+    using Clock = system_clock;
+#else
+    using Clock = steady_clock;
+#endif
+    const auto wake_time = Clock::now() + dur;
+    while (Clock::now() < wake_time)
         ;
 }
 




More information about the cfe-commits mailing list