From 4bbbedbb7ea3fd8179e7f021fd9471eddd394f35 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Sat, 1 Jun 2019 12:29:38 -0700 Subject: lib: Replace uhd::get_system_time() with steady_clock Benchmarks show that using C++ chrono features beats uhd::get_system_time(), and the latter is simply not appropriate unless a uhd::time_spec_t is required. --- host/lib/include/uhdlib/utils/atomic.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'host/lib/include/uhdlib/utils') diff --git a/host/lib/include/uhdlib/utils/atomic.hpp b/host/lib/include/uhdlib/utils/atomic.hpp index 5436eea81..303df1bc9 100644 --- a/host/lib/include/uhdlib/utils/atomic.hpp +++ b/host/lib/include/uhdlib/utils/atomic.hpp @@ -10,9 +10,9 @@ #include #include -#include #include #include +#include namespace uhd{ @@ -31,9 +31,10 @@ namespace uhd{ const double timeout ){ if (cond == value) return true; - const time_spec_t exit_time = uhd::get_system_time() + time_spec_t(timeout); + const auto exit_time = std::chrono::high_resolution_clock::now() + + std::chrono::microseconds(int64_t(timeout * 1e6)); while (cond != value) { - if (uhd::get_system_time() > exit_time) { + if (std::chrono::high_resolution_clock::now() > exit_time) { return false; } boost::this_thread::interruption_point(); -- cgit v1.2.3