aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2018-04-26 14:43:12 -0700
committerMartin Braun <martin.braun@ettus.com>2018-07-12 11:42:59 -0700
commit9df9bea6c1812fdc03ef8ace29859f0c64d382d2 (patch)
tree82d8b04ba9f892d15ff403fd9ed190f0b1f32569 /host/lib
parent05722dcc51a09084865736651e46326041dd6038 (diff)
downloaduhd-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')
-rw-r--r--host/lib/usrp/b200/b200_impl.cpp1
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.cpp21
-rw-r--r--host/lib/usrp/x300/x300_fw_uart.cpp10
-rw-r--r--host/lib/usrp/x300/x300_impl.cpp14
-rw-r--r--host/lib/usrp_clock/octoclock/octoclock_uart.cpp7
5 files changed, 32 insertions, 21 deletions
diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp
index a91bccf94..82f9fbff0 100644
--- a/host/lib/usrp/b200/b200_impl.cpp
+++ b/host/lib/usrp/b200/b200_impl.cpp
@@ -18,7 +18,6 @@
#include <uhd/usrp/dboard_eeprom.hpp>
#include <boost/format.hpp>
#include <boost/filesystem.hpp>
-#include <boost/thread/thread.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/functional/hash.hpp>
#include <boost/make_shared.hpp>
diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp
index 2bd573652..2134f8182 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.cpp
@@ -16,18 +16,20 @@
#include <uhd/utils/paths.hpp>
#include <boost/format.hpp>
#include <boost/filesystem.hpp>
-#include <boost/thread/thread.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/math/special_functions/round.hpp>
#include <cstdio>
+#include <chrono>
using namespace uhd;
using namespace uhd::usrp;
using namespace uhd::transport;
-const uint16_t USRP1_VENDOR_ID = 0xfffe;
-const uint16_t USRP1_PRODUCT_ID = 0x0002;
-static const boost::posix_time::milliseconds REENUMERATION_TIMEOUT_MS(3000);
+namespace {
+ constexpr uint16_t USRP1_VENDOR_ID = 0xfffe;
+ constexpr uint16_t USRP1_PRODUCT_ID = 0x0002;
+ constexpr int64_t REENUMERATION_TIMEOUT_MS = 3000;
+}
const std::vector<usrp1_impl::dboard_slot_t> usrp1_impl::_dboard_slots{
usrp1_impl::DBOARD_SLOT_A,
@@ -89,13 +91,14 @@ static device_addrs_t usrp1_find(const device_addr_t &hint)
vid = USRP1_VENDOR_ID;
pid = USRP1_PRODUCT_ID;
- const boost::system_time timeout_time = boost::get_system_time() + REENUMERATION_TIMEOUT_MS;
+ const auto timeout_time =
+ std::chrono::steady_clock::now()
+ + std::chrono::milliseconds(REENUMERATION_TIMEOUT_MS);
//search for the device until found or timeout
- while (boost::get_system_time() < timeout_time and usrp1_addrs.empty() and found != 0)
- {
- for(usb_device_handle::sptr handle: usb_device_handle::get_device_list(vid, pid))
- {
+ while (std::chrono::steady_clock::now() < timeout_time
+ and usrp1_addrs.empty() and found != 0) {
+ for (usb_device_handle::sptr handle : usb_device_handle::get_device_list(vid, pid)) {
usb_control::sptr control;
try{control = usb_control::make(handle, 0);}
catch(const uhd::exception &){continue;} //ignore claimed
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;
}
diff --git a/host/lib/usrp_clock/octoclock/octoclock_uart.cpp b/host/lib/usrp_clock/octoclock/octoclock_uart.cpp
index 74d324645..7fc455dda 100644
--- a/host/lib/usrp_clock/octoclock/octoclock_uart.cpp
+++ b/host/lib/usrp_clock/octoclock/octoclock_uart.cpp
@@ -78,7 +78,9 @@ namespace uhd{
std::string octoclock_uart_iface::read_uart(double timeout){
std::string result;
- boost::system_time exit_time = boost::get_system_time() + boost::posix_time::milliseconds(long(timeout*1e3));
+ const auto exit_time =
+ std::chrono::steady_clock::now()
+ + std::chrono::milliseconds(int64_t(timeout*1e3));
while(true)
{
@@ -93,8 +95,7 @@ namespace uhd{
return result;
}
}
- if (boost::get_system_time() > exit_time)
- {
+ if (std::chrono::steady_clock::now() > exit_time) {
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(1));