diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-04-26 14:43:12 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-07-12 11:42:59 -0700 |
commit | 9df9bea6c1812fdc03ef8ace29859f0c64d382d2 (patch) | |
tree | 82d8b04ba9f892d15ff403fd9ed190f0b1f32569 /host/lib/usrp/x300 | |
parent | 05722dcc51a09084865736651e46326041dd6038 (diff) | |
download | uhd-9df9bea6c1812fdc03ef8ace29859f0c64d382d2.tar.gz uhd-9df9bea6c1812fdc03ef8ace29859f0c64d382d2.tar.bz2 uhd-9df9bea6c1812fdc03ef8ace29859f0c64d382d2.zip |
lib: Purge some use of boost::system_time
These are all timeout loops, which now use
std::chrono::steady_clock::now() to check for timeout events.
Diffstat (limited to 'host/lib/usrp/x300')
-rw-r--r-- | host/lib/usrp/x300/x300_fw_uart.cpp | 10 | ||||
-rw-r--r-- | host/lib/usrp/x300/x300_impl.cpp | 14 |
2 files changed, 16 insertions, 8 deletions
diff --git a/host/lib/usrp/x300/x300_fw_uart.cpp b/host/lib/usrp/x300/x300_fw_uart.cpp index 3711cb48b..b6c2081ad 100644 --- a/host/lib/usrp/x300/x300_fw_uart.cpp +++ b/host/lib/usrp/x300/x300_fw_uart.cpp @@ -12,7 +12,7 @@ #include <uhd/types/serial.hpp> #include <uhd/exception.hpp> #include <boost/format.hpp> -#include <boost/thread/thread.hpp> +#include <chrono> using namespace uhd; @@ -126,7 +126,10 @@ struct x300_uart_iface : uart_iface std::string read_uart(double timeout) { boost::mutex::scoped_lock(_read_mutex); - const boost::system_time exit_time = boost::get_system_time() + boost::posix_time::microseconds(long(timeout*1e6)); + const auto exit_time = + std::chrono::steady_clock::now() + + std::chrono::microseconds(int64_t(timeout*1e6)); + std::string buff; while (true) @@ -149,8 +152,9 @@ struct x300_uart_iface : uart_iface } // no more characters - check time - if (boost::get_system_time() > exit_time) + if (std::chrono::steady_clock::now() > exit_time) { break; + } } return buff; diff --git a/host/lib/usrp/x300/x300_impl.cpp b/host/lib/usrp/x300/x300_impl.cpp index 2627ff1a2..b7fd58444 100644 --- a/host/lib/usrp/x300/x300_impl.cpp +++ b/host/lib/usrp/x300/x300_impl.cpp @@ -1583,8 +1583,10 @@ void x300_impl::claimer_loop(wb_iface::sptr iface) x300_impl::claim_status_t x300_impl::claim_status(wb_iface::sptr iface) { claim_status_t claim_status = CLAIMED_BY_OTHER; // Default to most restrictive - boost::system_time timeout_time = boost::get_system_time() + boost::posix_time::seconds(1); - while (boost::get_system_time() < timeout_time) + auto timeout_time = + std::chrono::steady_clock::now() + + std::chrono::seconds(1); + while (std::chrono::steady_clock::now() < timeout_time) { //If timed out, then device is definitely unclaimed if (iface->peek32(X300_FW_SHMEM_ADDR(X300_FW_SHMEM_CLAIM_STATUS)) == 0) @@ -1616,9 +1618,12 @@ void x300_impl::claim(wb_iface::sptr iface) iface->poke32(X300_FW_SHMEM_ADDR(X300_FW_SHMEM_CLAIM_SRC), get_process_hash()); } -bool x300_impl::try_to_claim(wb_iface::sptr iface, long timeout) +bool x300_impl::try_to_claim(wb_iface::sptr iface, long timeout_ms) { boost::system_time start_time = boost::get_system_time(); + const auto timeout_time = + std::chrono::steady_clock::now() + + std::chrono::milliseconds(timeout_ms); while (1) { claim_status_t status = claim_status(iface); @@ -1633,8 +1638,7 @@ bool x300_impl::try_to_claim(wb_iface::sptr iface, long timeout) { break; } - if (boost::get_system_time() - start_time > boost::posix_time::milliseconds(timeout)) - { + if (std::chrono::steady_clock::now() > timeout_time) { // Another process owns the device - give up return false; } |