forked from OSchip/llvm-project
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. llvm-svn: 273091
This commit is contained in:
parent
03a899957f
commit
824ed8c03e
|
@ -388,9 +388,13 @@ inline std::error_code GetTestEC() {
|
||||||
// available in single-threaded mode.
|
// available in single-threaded mode.
|
||||||
void SleepFor(std::chrono::seconds dur) {
|
void SleepFor(std::chrono::seconds dur) {
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
const auto curr_time = steady_clock::now();
|
#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
|
||||||
auto wake_time = curr_time + dur;
|
using Clock = system_clock;
|
||||||
while (steady_clock::now() < wake_time)
|
#else
|
||||||
|
using Clock = steady_clock;
|
||||||
|
#endif
|
||||||
|
const auto wake_time = Clock::now() + dur;
|
||||||
|
while (Clock::now() < wake_time)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue