diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-06-01 12:29:38 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 11:49:12 -0800 |
commit | 4bbbedbb7ea3fd8179e7f021fd9471eddd394f35 (patch) | |
tree | fcfc87c04bedfccdf16a7d0f64dcbb6a8d7f64b0 /host/lib/include/uhdlib/utils | |
parent | 56f21097483da8aa5d8787a75a1b22a0c4c41313 (diff) | |
download | uhd-4bbbedbb7ea3fd8179e7f021fd9471eddd394f35.tar.gz uhd-4bbbedbb7ea3fd8179e7f021fd9471eddd394f35.tar.bz2 uhd-4bbbedbb7ea3fd8179e7f021fd9471eddd394f35.zip |
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.
Diffstat (limited to 'host/lib/include/uhdlib/utils')
-rw-r--r-- | host/lib/include/uhdlib/utils/atomic.hpp | 7 |
1 files changed, 4 insertions, 3 deletions
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 <uhd/config.hpp> #include <uhd/types/time_spec.hpp> -#include <uhdlib/utils/system_time.hpp> #include <boost/thread/thread.hpp> #include <atomic> +#include <chrono> 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(); |