aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2021-07-06 16:51:55 +0200
committerAaron Rossetto <aaron.rossetto@ni.com>2021-10-19 12:21:33 -0700
commitb6119e581e6ea9273b188463dc4529c30db140ba (patch)
tree11517bfd9cff0f0e37120b10c72b4387f7d509a6
parent01d81c7fa5e43210a40c61ce39287c7be245f7c4 (diff)
downloaduhd-b6119e581e6ea9273b188463dc4529c30db140ba.tar.gz
uhd-b6119e581e6ea9273b188463dc4529c30db140ba.tar.bz2
uhd-b6119e581e6ea9273b188463dc4529c30db140ba.zip
uhd: Replace Boost mutexes and locks with standard options
This is a very mechanical task that could almost have been done with sed. Boost versions of mutexes and locks were removed, and replaced with std:: versions. The replacement tables are as follows: == Mutexes == - boost::mutex -> std::mutex - boost::recursive_mutex -> std::recursive_mutex Mutexes behave identically between Boost and std:: and have the same API. == Locks == C++11 has only two types of lock that we use/need in UHD: - std::lock_guard: Identical to boost::lock_guard - std::unique_lock: Identical to boost::unique_lock Boost also has boost::mutex::scoped_lock, which is a typedef for boost::unique_lock<>. However, we often have used scoped_lock where we meant to use lock_guard<>. The name is a bit misleading, "scoped lock" sounding a bit like an RAII mechanism. Therefore, some previous boost::mutex::scoped_lock are now std::lock_guard<>. std::unique_lock is required when doing more than RAII locking (i.e., unlocking, relocking, usage with condition variables, etc.). == Condition Variables == Condition variables were out of the scope of this lock/mutex change, but in UHD, we inconsistently use boost::condition vs. boost::condition_variable. The former is a templated version of the latter, and thus works fine with std::mutex'es. Therefore, some boost::condition_variable where changed to boost::condition. All locks and mutexes use `#include <mutex>`. The corresponding Boost includes were removed. In some cases, this exposed issues with implicit Boost includes elsewhere. The missing explicit includes were added.
-rw-r--r--host/examples/network_relay.cpp18
-rw-r--r--host/include/uhd/transport/bounded_buffer.ipp33
-rw-r--r--host/include/uhd/transport/nirio/nirio_fifo.h8
-rw-r--r--host/include/uhd/transport/nirio/nirio_fifo.ipp16
-rw-r--r--host/include/uhd/transport/nirio/niusrprio_session.h6
-rw-r--r--host/include/uhd/transport/nirio/rpc/rpc_client.hpp10
-rw-r--r--host/include/uhd/utils/soft_register.hpp37
-rw-r--r--host/lib/device.cpp17
-rw-r--r--host/lib/error_c.cpp8
-rw-r--r--host/lib/experts/expert_container.cpp26
-rw-r--r--host/lib/include/uhdlib/experts/expert_container.hpp4
-rw-r--r--host/lib/include/uhdlib/experts/expert_nodes.hpp18
-rw-r--r--host/lib/include/uhdlib/usrp/common/recv_packet_demuxer_3000.hpp10
-rw-r--r--host/lib/property_tree.cpp19
-rw-r--r--host/lib/transport/libusb1_base.cpp5
-rw-r--r--host/lib/transport/libusb1_control.cpp6
-rw-r--r--host/lib/transport/libusb1_zero_copy.cpp30
-rw-r--r--host/lib/transport/muxed_zero_copy_if.cpp12
-rw-r--r--host/lib/transport/nirio/niusrprio_session.cpp8
-rw-r--r--host/lib/transport/nirio/rpc/rpc_client.cpp6
-rw-r--r--host/lib/transport/nirio_link.cpp1
-rw-r--r--host/lib/usrp/b100/usb_zero_copy_wrapper.cpp15
-rw-r--r--host/lib/usrp/b200/b200_radio_ctrl_core.cpp17
-rw-r--r--host/lib/usrp/common/recv_packet_demuxer.cpp6
-rw-r--r--host/lib/usrp/cores/i2c_core_200.cpp8
-rw-r--r--host/lib/usrp/cores/user_settings_core_3000.cpp8
-rw-r--r--host/lib/usrp/dboard/db_ubx.cpp28
-rw-r--r--host/lib/usrp/dboard/twinrx/twinrx_ctrl.cpp52
-rw-r--r--host/lib/usrp/dboard/twinrx/twinrx_io.hpp10
-rw-r--r--host/lib/usrp/gps_ctrl.cpp11
-rw-r--r--host/lib/usrp/usrp1/soft_time_ctrl.cpp22
-rw-r--r--host/lib/usrp/usrp2/io_impl.cpp6
-rw-r--r--host/lib/usrp/usrp2/usrp2_fifo_ctrl.cpp20
-rw-r--r--host/lib/usrp/usrp2/usrp2_iface.cpp5
-rw-r--r--host/lib/usrp/usrp_c.cpp38
-rw-r--r--host/lib/usrp/x300/x300_fw_ctrl.cpp10
-rw-r--r--host/lib/usrp/x300/x300_fw_uart.cpp10
-rw-r--r--host/lib/usrp_clock/octoclock/octoclock_impl.hpp4
-rw-r--r--host/lib/usrp_clock/usrp_clock_c.cpp14
-rw-r--r--host/lib/utils/tasks.cpp7
40 files changed, 292 insertions, 297 deletions
diff --git a/host/examples/network_relay.cpp b/host/examples/network_relay.cpp
index 15c6de4ef..910584452 100644
--- a/host/examples/network_relay.cpp
+++ b/host/examples/network_relay.cpp
@@ -8,15 +8,15 @@
#include <uhd/utils/safe_main.hpp>
#include <uhd/utils/thread.hpp>
#include <boost/asio.hpp>
-#include <boost/format.hpp>
#include <boost/program_options.hpp>
-#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/condition.hpp>
#include <boost/thread/thread.hpp>
#include <chrono>
#include <csignal>
#include <cstdlib>
#include <functional>
#include <iostream>
+#include <mutex>
#include <thread>
#include <vector>
@@ -99,7 +99,7 @@ public:
}
std::cout << "spawning relay threads... " << _port << std::endl;
- boost::unique_lock<boost::mutex> lock(
+ std::unique_lock<std::mutex> lock(
spawn_mutex); // lock in preparation to wait for threads to spawn
(void)_thread_group.create_thread(
std::bind(&udp_relay_type::server_thread, this));
@@ -134,7 +134,7 @@ private:
std::vector<char> buff(insane_mtu);
while (not boost::this_thread::interruption_requested()) {
if (wait_for_recv_ready(_server_socket->native_handle())) {
- boost::mutex::scoped_lock lock(_endpoint_mutex);
+ std::unique_lock<std::mutex> lock(_endpoint_mutex);
const size_t len = _server_socket->receive_from(
asio::buffer(&buff.front(), buff.size()), _endpoint);
lock.unlock();
@@ -164,7 +164,7 @@ private:
if (wait_for_recv_ready(_client_socket->native_handle())) {
const size_t len =
_client_socket->receive(asio::buffer(&buff.front(), buff.size()));
- boost::mutex::scoped_lock lock(_endpoint_mutex);
+ std::lock_guard<std::mutex> lock(_endpoint_mutex);
_server_socket->send_to(asio::buffer(&buff.front(), len), _endpoint);
}
}
@@ -175,10 +175,10 @@ private:
boost::thread_group _thread_group;
asio::io_service _io_service;
asio::ip::udp::endpoint _endpoint;
- boost::mutex _endpoint_mutex;
+ std::mutex _endpoint_mutex;
socket_type _server_socket, _client_socket;
- boost::mutex spawn_mutex;
- boost::condition_variable wait_for_thread;
+ std::mutex spawn_mutex;
+ boost::condition wait_for_thread;
};
@@ -206,7 +206,7 @@ int UHD_SAFE_MAIN(int argc, char* argv[])
// print the help message
if (vm.count("help") or not vm.count("addr")) {
- std::cout << boost::format("UHD Network Relay %s") % desc << std::endl
+ std::cout << "UHD Network Relay " << desc << std::endl
<< "Runs a network relay between UHD on one computer and a USRP on the "
"network.\n"
<< "This example is basically for test purposes. Use at your own "
diff --git a/host/include/uhd/transport/bounded_buffer.ipp b/host/include/uhd/transport/bounded_buffer.ipp
index 3e15fc03a..122b3d740 100644
--- a/host/include/uhd/transport/bounded_buffer.ipp
+++ b/host/include/uhd/transport/bounded_buffer.ipp
@@ -11,9 +11,9 @@
#include <uhd/utils/noncopyable.hpp>
#include <boost/circular_buffer.hpp>
#include <boost/thread/condition.hpp>
-#include <boost/thread/locks.hpp>
#include <boost/utility.hpp>
#include <functional>
+#include <mutex>
namespace uhd{ namespace transport{
@@ -30,9 +30,8 @@ namespace uhd{ namespace transport{
UHD_INLINE bool push_with_haste(const elem_type &elem)
{
- boost::mutex::scoped_lock lock(_mutex);
- if (_buffer.full())
- {
+ std::unique_lock<std::mutex> lock(_mutex);
+ if (_buffer.full()) {
return false;
}
_buffer.push_front(elem);
@@ -42,15 +41,13 @@ namespace uhd{ namespace transport{
UHD_INLINE bool push_with_pop_on_full(const elem_type &elem)
{
- boost::mutex::scoped_lock lock(_mutex);
- if (_buffer.full())
- {
+ std::lock_guard<std::mutex> lock(_mutex);
+ if (_buffer.full()) {
_buffer.pop_back();
_buffer.push_front(elem);
_empty_cond.notify_one();
return false;
- }
- else {
+ } else {
_buffer.push_front(elem);
_empty_cond.notify_one();
return true;
@@ -59,7 +56,7 @@ namespace uhd{ namespace transport{
UHD_INLINE void push_with_wait(const elem_type &elem)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::unique_lock<std::mutex> lock(_mutex);
if (_buffer.full())
{
_full_cond.wait(lock, _not_full_fcn);
@@ -70,7 +67,7 @@ namespace uhd{ namespace transport{
UHD_INLINE bool push_with_timed_wait(const elem_type &elem, double timeout)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::unique_lock<std::mutex> lock(_mutex);
if (_buffer.full())
{
if (not _full_cond.timed_wait(lock,
@@ -86,9 +83,8 @@ namespace uhd{ namespace transport{
UHD_INLINE bool pop_with_haste(elem_type &elem)
{
- boost::mutex::scoped_lock lock(_mutex);
- if (_buffer.empty())
- {
+ std::unique_lock<std::mutex> lock(_mutex);
+ if (_buffer.empty()) {
return false;
}
this->pop_back(elem);
@@ -98,7 +94,7 @@ namespace uhd{ namespace transport{
UHD_INLINE void pop_with_wait(elem_type &elem)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::unique_lock<std::mutex> lock(_mutex);
if (_buffer.empty())
{
_empty_cond.wait(lock, _not_empty_fcn);
@@ -109,9 +105,8 @@ namespace uhd{ namespace transport{
UHD_INLINE bool pop_with_timed_wait(elem_type &elem, double timeout)
{
- boost::mutex::scoped_lock lock(_mutex);
- if (_buffer.empty())
- {
+ std::unique_lock<std::mutex> lock(_mutex);
+ if (_buffer.empty()) {
if (not _empty_cond.timed_wait(lock, to_time_dur(timeout),
_not_empty_fcn))
{
@@ -124,7 +119,7 @@ namespace uhd{ namespace transport{
}
private:
- boost::mutex _mutex;
+ std::mutex _mutex;
boost::condition _empty_cond, _full_cond;
boost::circular_buffer<elem_type> _buffer;
diff --git a/host/include/uhd/transport/nirio/nirio_fifo.h b/host/include/uhd/transport/nirio/nirio_fifo.h
index 0cd9f1906..71b9563c3 100644
--- a/host/include/uhd/transport/nirio/nirio_fifo.h
+++ b/host/include/uhd/transport/nirio/nirio_fifo.h
@@ -13,12 +13,12 @@
#include <uhd/transport/nirio/niriok_proxy.h>
#include <uhd/transport/nirio/status.h>
#include <uhd/utils/noncopyable.hpp>
-#include <boost/thread/recursive_mutex.hpp>
#include <atomic>
-#include <string>
#include <chrono>
+#include <cstdint>
+#include <mutex>
+#include <string>
#include <thread>
-#include <stdint.h>
namespace uhd { namespace niusrprio {
@@ -213,7 +213,7 @@ private: //Members
size_t _remaining_in_claimed_block;
size_t _remaining_acquirable_elements;
nirio_driver_iface::rio_mmap_t _mem_map;
- boost::recursive_mutex _mutex;
+ std::recursive_mutex _mutex;
niriok_proxy::sptr _riok_proxy_ptr;
uint64_t _expected_xfer_count;
diff --git a/host/include/uhd/transport/nirio/nirio_fifo.ipp b/host/include/uhd/transport/nirio/nirio_fifo.ipp
index 048616b4c..12058aa70 100644
--- a/host/include/uhd/transport/nirio/nirio_fifo.ipp
+++ b/host/include/uhd/transport/nirio/nirio_fifo.ipp
@@ -61,7 +61,7 @@ nirio_status nirio_fifo<data_t>::initialize(
{
nirio_status status = NiRio_Status_Success;
if (!_riok_proxy_ptr) return NiRio_Status_ResourceNotInitialized;
- boost::unique_lock<boost::recursive_mutex> lock(_mutex);
+ std::unique_lock<std::recursive_mutex> lock(_mutex);
if (_state == UNMAPPED) {
@@ -101,7 +101,7 @@ nirio_status nirio_fifo<data_t>::initialize(
template <typename data_t>
void nirio_fifo<data_t>::finalize()
{
- boost::unique_lock<boost::recursive_mutex> lock(_mutex);
+ std::unique_lock<std::recursive_mutex> lock(_mutex);
//If the FIFO is started, the stop will change the state to MAPPED.
stop();
@@ -200,7 +200,7 @@ nirio_status nirio_fifo<data_t>::start()
nirio_status status = NiRio_Status_Success;
if (!_riok_proxy_ptr) return NiRio_Status_ResourceNotInitialized;
- boost::unique_lock<boost::recursive_mutex> lock(_mutex);
+ std::unique_lock<std::recursive_mutex> lock(_mutex);
if (_state == STARTED) {
//Do nothing. Already started.
@@ -237,7 +237,7 @@ nirio_status nirio_fifo<data_t>::stop()
nirio_status status = NiRio_Status_Success;
if (!_riok_proxy_ptr) return NiRio_Status_ResourceNotInitialized;
- boost::unique_lock<boost::recursive_mutex> lock(_mutex);
+ std::unique_lock<std::recursive_mutex> lock(_mutex);
if (_state == STARTED) {
@@ -266,7 +266,7 @@ nirio_status nirio_fifo<data_t>::acquire(
nirio_status status = NiRio_Status_Success;
if (!_riok_proxy_ptr || _mem_map.is_null()) return NiRio_Status_ResourceNotInitialized;
- boost::unique_lock<boost::recursive_mutex> lock(_mutex);
+ std::unique_lock<std::recursive_mutex> lock(_mutex);
if (_state == STARTED) {
@@ -320,7 +320,7 @@ nirio_status nirio_fifo<data_t>::release(const size_t elements)
nirio_status status = NiRio_Status_Success;
if (!_riok_proxy_ptr) return NiRio_Status_ResourceNotInitialized;
- boost::unique_lock<boost::recursive_mutex> lock(_mutex);
+ std::unique_lock<std::recursive_mutex> lock(_mutex);
if (_state == STARTED) {
status = _riok_proxy_ptr->grant_fifo(
@@ -345,7 +345,7 @@ nirio_status nirio_fifo<data_t>::read(
nirio_status status = NiRio_Status_Success;
if (!_riok_proxy_ptr) return NiRio_Status_ResourceNotInitialized;
- boost::unique_lock<boost::recursive_mutex> lock(_mutex);
+ std::unique_lock<std::recursive_mutex> lock(_mutex);
if (_state == STARTED) {
status = _riok_proxy_ptr->read_fifo(
@@ -375,7 +375,7 @@ nirio_status nirio_fifo<data_t>::write(
nirio_status status = NiRio_Status_Success;
if (!_riok_proxy_ptr) return NiRio_Status_ResourceNotInitialized;
- boost::unique_lock<boost::recursive_mutex> lock(_mutex);
+ std::unique_lock<std::recursive_mutex> lock(_mutex);
if (_state == STARTED) {
status = _riok_proxy_ptr->write_fifo(
diff --git a/host/include/uhd/transport/nirio/niusrprio_session.h b/host/include/uhd/transport/nirio/niusrprio_session.h
index 183f766cc..432c3cd90 100644
--- a/host/include/uhd/transport/nirio/niusrprio_session.h
+++ b/host/include/uhd/transport/nirio/niusrprio_session.h
@@ -13,8 +13,8 @@
#include <uhd/transport/nirio/niriok_proxy.h>
#include <uhd/transport/nirio/rpc/usrprio_rpc_client.hpp>
#include <uhd/utils/noncopyable.hpp>
-#include <stdint.h>
-#include <boost/thread/recursive_mutex.hpp>
+#include <cstdint>
+#include <mutex>
#include <string>
namespace uhd { namespace niusrprio {
@@ -103,7 +103,7 @@ private:
niriok_proxy::sptr _riok_proxy;
nirio_resource_manager _resource_manager;
usrprio_rpc::usrprio_rpc_client _rpc_client;
- boost::recursive_mutex _session_mutex;
+ std::recursive_mutex _session_mutex;
};
}} // namespace uhd::niusrprio
diff --git a/host/include/uhd/transport/nirio/rpc/rpc_client.hpp b/host/include/uhd/transport/nirio/rpc/rpc_client.hpp
index 9361b7276..844e36c76 100644
--- a/host/include/uhd/transport/nirio/rpc/rpc_client.hpp
+++ b/host/include/uhd/transport/nirio/rpc/rpc_client.hpp
@@ -11,9 +11,11 @@
#include <uhd/utils/log.hpp>
#include <uhd/utils/noncopyable.hpp>
#include <boost/asio.hpp>
-#include <boost/thread/condition_variable.hpp>
-#include <boost/thread/thread.hpp>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
+#include <boost/thread.hpp>
+#include <boost/thread/condition.hpp>
#include <memory>
+#include <mutex>
namespace uhd { namespace usrprio_rpc {
@@ -76,8 +78,8 @@ private:
func_xport_buf_t _request;
func_xport_buf_t _response;
// Synchronization
- boost::mutex _mutex;
- boost::condition_variable _exec_gate;
+ std::mutex _mutex;
+ boost::condition _exec_gate;
boost::system::error_code _exec_err;
};
diff --git a/host/include/uhd/utils/soft_register.hpp b/host/include/uhd/utils/soft_register.hpp
index e38ffedfe..d23d1b8fb 100644
--- a/host/include/uhd/utils/soft_register.hpp
+++ b/host/include/uhd/utils/soft_register.hpp
@@ -11,12 +11,11 @@
#include <uhd/types/wb_iface.hpp>
#include <uhd/utils/dirty_tracked.hpp>
#include <uhd/utils/noncopyable.hpp>
-#include <stdint.h>
#include <unordered_map>
-#include <boost/thread/locks.hpp>
-#include <boost/thread/mutex.hpp>
#include <boost/tokenizer.hpp>
+#include <cstdint>
#include <list>
+#include <mutex>
/*! \file soft_register.hpp
* Utilities to access and index hardware registers.
@@ -329,48 +328,48 @@ public:
UHD_INLINE void initialize(wb_iface& iface, bool sync = false)
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
soft_register_t<reg_data_t, readable, writable>::initialize(iface, sync);
}
UHD_INLINE void set(const soft_reg_field_t field, const reg_data_t value)
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
soft_register_t<reg_data_t, readable, writable>::set(field, value);
}
UHD_INLINE reg_data_t get(const soft_reg_field_t field)
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
return soft_register_t<reg_data_t, readable, writable>::get(field);
}
UHD_INLINE void flush()
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
soft_register_t<reg_data_t, readable, writable>::flush();
}
UHD_INLINE void refresh()
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
soft_register_t<reg_data_t, readable, writable>::refresh();
}
UHD_INLINE void write(const soft_reg_field_t field, const reg_data_t value)
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
soft_register_t<reg_data_t, readable, writable>::write(field, value);
}
UHD_INLINE reg_data_t read(const soft_reg_field_t field)
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
return soft_register_t<reg_data_t, readable, writable>::read(field);
}
private:
- boost::mutex _mutex;
+ std::mutex _mutex;
};
/*
@@ -483,7 +482,7 @@ public:
*/
void initialize(wb_iface& iface, bool sync = false)
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
for (soft_register_base* reg : _reglist) {
reg->initialize(iface, sync);
}
@@ -496,7 +495,7 @@ public:
*/
void flush()
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
for (soft_register_base* reg : _reglist) {
reg->flush();
}
@@ -509,7 +508,7 @@ public:
*/
void refresh()
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
for (soft_register_base* reg : _reglist) {
reg->refresh();
}
@@ -555,7 +554,7 @@ protected:
const std::string& name,
const visibility_t visible = PRIVATE)
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
if (visible == PUBLIC) {
// Only add to the map if this register is publicly visible
if (not _regmap.insert(regmap_t::value_type(name, &reg)).second) {
@@ -573,7 +572,7 @@ private:
const std::string _name;
regmap_t _regmap; // For lookups
reglist_t _reglist; // To maintain order
- boost::mutex _mutex;
+ std::mutex _mutex;
};
@@ -611,7 +610,7 @@ public:
*/
void add(soft_regmap_t& regmap)
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
_regmaps.push_back(&regmap);
}
@@ -620,7 +619,7 @@ public:
*/
void add(soft_regmap_db_t& db)
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
if (&db == this) {
throw uhd::assertion_error("cannot add regmap db to itself" + _name);
} else {
@@ -700,7 +699,7 @@ private:
const std::string _name;
db_t _regmaps;
db_t _regmap_dbs;
- boost::mutex _mutex;
+ std::mutex _mutex;
};
} // namespace uhd
diff --git a/host/lib/device.cpp b/host/lib/device.cpp
index 62277134b..0d64b4f4c 100644
--- a/host/lib/device.cpp
+++ b/host/lib/device.cpp
@@ -12,16 +12,15 @@
#include <uhd/utils/log.hpp>
#include <uhd/utils/static.hpp>
#include <uhdlib/utils/prefs.hpp>
-#include <boost/format.hpp>
#include <boost/functional/hash.hpp>
-#include <boost/thread/mutex.hpp>
#include <future>
#include <memory>
+#include <mutex>
#include <tuple>
using namespace uhd;
-static boost::mutex _device_mutex;
+static std::mutex _device_mutex;
/***********************************************************************
* Helper Functions
@@ -82,7 +81,7 @@ device::~device(void)
**********************************************************************/
device_addrs_t device::find(const device_addr_t& hint, device_filter_t filter)
{
- boost::mutex::scoped_lock lock(_device_mutex);
+ std::lock_guard<std::mutex> lock(_device_mutex);
device_addrs_t device_addrs;
std::vector<std::future<device_addrs_t>> find_tasks;
@@ -110,7 +109,7 @@ device_addrs_t device::find(const device_addr_t& hint, device_filter_t filter)
**********************************************************************/
device::sptr device::make(const device_addr_t& hint, device_filter_t filter, size_t which)
{
- boost::mutex::scoped_lock lock(_device_mutex);
+ std::lock_guard<std::mutex> lock(_device_mutex);
typedef std::tuple<device_addr_t, make_t> dev_addr_make_t;
std::vector<dev_addr_make_t> dev_addr_makers;
@@ -132,13 +131,13 @@ device::sptr device::make(const device_addr_t& hint, device_filter_t filter, siz
// check that we found any devices
if (dev_addr_makers.empty()) {
throw uhd::key_error(
- str(boost::format("No devices found for ----->\n%s") % hint.to_pp_string()));
+ std::string("No devices found for ----->\n") + hint.to_pp_string());
}
// check that the which index is valid
if (dev_addr_makers.size() <= which) {
- throw uhd::index_error(str(boost::format("No device at index %d for ----->\n%s")
- % which % hint.to_pp_string()));
+ throw uhd::index_error("No device at index " + std::to_string(which)
+ + " for ----->\n" + hint.to_pp_string());
}
// create a unique hash for the device address
@@ -146,7 +145,7 @@ device::sptr device::make(const device_addr_t& hint, device_filter_t filter, siz
make_t maker;
std::tie(dev_addr, maker) = dev_addr_makers.at(which);
size_t dev_hash = hash_device_addr(dev_addr);
- UHD_LOGGER_TRACE("UHD") << boost::format("Device hash: %u") % dev_hash;
+ UHD_LOGGER_TRACE("UHD") << "Device hash: " << dev_hash;
// copy keys that were in hint but not in dev_addr
// this way, we can pass additional transport arguments
diff --git a/host/lib/error_c.cpp b/host/lib/error_c.cpp
index 0914ca4e7..fcfa5ce06 100644
--- a/host/lib/error_c.cpp
+++ b/host/lib/error_c.cpp
@@ -8,8 +8,8 @@
#include <uhd/error.h>
#include <uhd/exception.hpp>
#include <uhd/utils/static.hpp>
-#include <boost/thread/mutex.hpp>
#include <cstring>
+#include <mutex>
#define MAP_TO_ERROR(exception_type, error_type) \
if (dynamic_cast<const uhd::exception_type*>(e)) \
@@ -40,17 +40,17 @@ uhd_error error_from_uhd_exception(const uhd::exception* e)
// get_c_global_error_string() instead.
UHD_SINGLETON_FCN(std::string, _c_global_error_string)
-static boost::mutex _error_c_mutex;
+static std::mutex _error_c_mutex;
std::string get_c_global_error_string()
{
- boost::mutex::scoped_lock lock(_error_c_mutex);
+ std::lock_guard<std::mutex> lock(_error_c_mutex);
return _c_global_error_string();
}
void set_c_global_error_string(const std::string& msg)
{
- boost::mutex::scoped_lock lock(_error_c_mutex);
+ std::lock_guard<std::mutex> lock(_error_c_mutex);
_c_global_error_string() = msg;
}
diff --git a/host/lib/experts/expert_container.cpp b/host/lib/experts/expert_container.cpp
index 0658e9fa3..0fc159a98 100644
--- a/host/lib/experts/expert_container.cpp
+++ b/host/lib/experts/expert_container.cpp
@@ -14,9 +14,9 @@
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/topological_sort.hpp>
#include <boost/thread.hpp>
-#include <boost/thread/mutex.hpp>
#include <functional>
#include <memory>
+#include <mutex>
#ifdef UHD_EXPERT_LOGGING
# define EX_LOG(depth, str) _log(depth, str)
@@ -79,8 +79,8 @@ public:
void resolve_all(bool force = false) override
{
- boost::lock_guard<boost::recursive_mutex> resolve_lock(_resolve_mutex);
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::recursive_mutex> resolve_lock(_resolve_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
EX_LOG(0, str(boost::format("resolve_all(%s)") % (force ? "force" : "")));
// Do a full resolve of the graph
_resolve_helper("", "", force);
@@ -88,8 +88,8 @@ public:
void resolve_from(const std::string&) override
{
- boost::lock_guard<boost::recursive_mutex> resolve_lock(_resolve_mutex);
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::recursive_mutex> resolve_lock(_resolve_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
EX_LOG(0, "resolve_from (overridden to resolve_all)");
// Do a full resolve of the graph
// Not optimizing the traversal using node_name to reduce experts complexity
@@ -98,8 +98,8 @@ public:
void resolve_to(const std::string&) override
{
- boost::lock_guard<boost::recursive_mutex> resolve_lock(_resolve_mutex);
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::recursive_mutex> resolve_lock(_resolve_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
EX_LOG(0, "resolve_to (overridden to resolve_all)");
// Do a full resolve of the graph
// Not optimizing the traversal using node_name to reduce experts complexity
@@ -271,7 +271,7 @@ public:
#endif
}
- inline boost::recursive_mutex& resolve_mutex() override
+ inline std::recursive_mutex& resolve_mutex() override
{
return _resolve_mutex;
}
@@ -279,7 +279,7 @@ public:
protected:
void add_data_node(dag_vertex_t* data_node, auto_resolve_mode_t resolve_mode) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
// Sanity check node pointer
if (data_node == NULL) {
@@ -330,7 +330,7 @@ protected:
void add_worker(worker_node_t* worker) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
// Sanity check node pointer
if (worker == NULL) {
@@ -400,7 +400,7 @@ protected:
void clear() override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
EX_LOG(0, "clear()");
// Iterate through the vertices and release their node storage
@@ -553,8 +553,8 @@ private:
vertex_map_t _worker_map; // A map from vertex name to vertex descriptor for workers
vertex_map_t
_datanode_map; // A map from vertex name to vertex descriptor for data nodes
- boost::mutex _mutex;
- boost::recursive_mutex _resolve_mutex;
+ std::mutex _mutex;
+ std::recursive_mutex _resolve_mutex;
};
expert_container::sptr expert_container::make(const std::string& name)
diff --git a/host/lib/include/uhdlib/experts/expert_container.hpp b/host/lib/include/uhdlib/experts/expert_container.hpp
index bb05ae334..c794e9d8c 100644
--- a/host/lib/include/uhdlib/experts/expert_container.hpp
+++ b/host/lib/include/uhdlib/experts/expert_container.hpp
@@ -10,8 +10,8 @@
#include <uhd/config.hpp>
#include <uhd/utils/noncopyable.hpp>
#include <uhdlib/experts/expert_nodes.hpp>
-#include <boost/thread/recursive_mutex.hpp>
#include <memory>
+#include <mutex>
namespace uhd { namespace experts {
@@ -153,7 +153,7 @@ private:
* container.
*
*/
- virtual boost::recursive_mutex& resolve_mutex() = 0;
+ virtual std::recursive_mutex& resolve_mutex() = 0;
/*!
* Add a data node to the expert graph
diff --git a/host/lib/include/uhdlib/experts/expert_nodes.hpp b/host/lib/include/uhdlib/experts/expert_nodes.hpp
index ce061ca26..66dd0f246 100644
--- a/host/lib/include/uhdlib/experts/expert_nodes.hpp
+++ b/host/lib/include/uhdlib/experts/expert_nodes.hpp
@@ -14,11 +14,12 @@
#include <uhd/utils/noncopyable.hpp>
#include <stdint.h>
#include <boost/core/demangle.hpp>
-#include <boost/thread.hpp>
-#include <boost/thread/recursive_mutex.hpp>
#include <functional>
#include <list>
#include <memory>
+#include <mutex>
+#include <sstream>
+#include <thread>
namespace uhd { namespace experts {
@@ -130,7 +131,7 @@ public:
// from the outside world (of experts) using read and write callbacks. We
// assume that if a callback mutex is passed into the data node that it will
// be accessed from the outside and tag the data node as a PROPERTY.
- data_node_t(const std::string& name, boost::recursive_mutex* mutex = NULL)
+ data_node_t(const std::string& name, std::recursive_mutex* mutex = NULL)
: dag_vertex_t(mutex ? CLASS_PROPERTY : CLASS_DATA, name)
, _callback_mutex(mutex)
, _data()
@@ -138,9 +139,8 @@ public:
{
}
- data_node_t(const std::string& name,
- const data_t& value,
- boost::recursive_mutex* mutex = NULL)
+ data_node_t(
+ const std::string& name, const data_t& value, std::recursive_mutex* mutex = NULL)
: dag_vertex_t(mutex ? CLASS_PROPERTY : CLASS_DATA, name)
, _callback_mutex(mutex)
, _data(value)
@@ -199,7 +199,7 @@ public:
if (_callback_mutex == NULL)
throw uhd::assertion_error(
"node " + get_name() + " is missing the callback mutex");
- boost::lock_guard<boost::recursive_mutex> lock(*_callback_mutex);
+ std::lock_guard<std::recursive_mutex> lock(*_callback_mutex);
set(value);
_author = AUTHOR_USER;
if (is_dirty() and has_write_callback()) {
@@ -213,7 +213,7 @@ public:
if (_callback_mutex == NULL)
throw uhd::assertion_error(
"node " + get_name() + " is missing the callback mutex");
- boost::lock_guard<boost::recursive_mutex> lock(*_callback_mutex);
+ std::lock_guard<std::recursive_mutex> lock(*_callback_mutex);
if (has_read_callback()) {
_rd_callback(std::string(get_name()));
}
@@ -252,7 +252,7 @@ private:
_rd_callback = nullptr;
}
- boost::recursive_mutex* _callback_mutex;
+ std::recursive_mutex* _callback_mutex;
callback_func_t _rd_callback;
callback_func_t _wr_callback;
dirty_tracked<data_t> _data;
diff --git a/host/lib/include/uhdlib/usrp/common/recv_packet_demuxer_3000.hpp b/host/lib/include/uhdlib/usrp/common/recv_packet_demuxer_3000.hpp
index 0e1041642..7fa24f046 100644
--- a/host/lib/include/uhdlib/usrp/common/recv_packet_demuxer_3000.hpp
+++ b/host/lib/include/uhdlib/usrp/common/recv_packet_demuxer_3000.hpp
@@ -13,10 +13,10 @@
#include <uhd/utils/byteswap.hpp>
#include <uhd/utils/log.hpp>
#include <stdint.h>
-#include <boost/thread.hpp>
#include <chrono>
#include <map>
#include <memory>
+#include <mutex>
#include <queue>
namespace uhd { namespace usrp {
@@ -62,7 +62,7 @@ struct recv_packet_demuxer_3000 : std::enable_shared_from_this<recv_packet_demux
//-- Check the queue to see if we already have a buffer
//----------------------------------------------------------
{
- boost::mutex::scoped_lock l(mutex);
+ std::lock_guard<std::mutex> l(mutex);
queue_type_t& queue = _queues[sid];
if (not queue.empty()) {
buff = queue.front();
@@ -76,7 +76,7 @@ struct recv_packet_demuxer_3000 : std::enable_shared_from_this<recv_packet_demux
if (buff) {
const uint32_t new_sid = uhd::wtohx(buff->cast<const uint32_t*>()[1]);
if (new_sid != sid) {
- boost::mutex::scoped_lock l(mutex);
+ std::lock_guard<std::mutex> l(mutex);
if (_queues.count(new_sid) == 0)
UHD_LOGGER_ERROR("STREAMER")
<< "recv packet demuxer unexpected sid 0x" << std::hex
@@ -92,7 +92,7 @@ struct recv_packet_demuxer_3000 : std::enable_shared_from_this<recv_packet_demux
void realloc_sid(const uint32_t sid)
{
- boost::mutex::scoped_lock l(mutex);
+ std::lock_guard<std::mutex> l(mutex);
while (not _queues[sid].empty()) // allocated and clears if already allocated
{
_queues[sid].pop();
@@ -104,7 +104,7 @@ struct recv_packet_demuxer_3000 : std::enable_shared_from_this<recv_packet_demux
typedef std::queue<transport::managed_recv_buffer::sptr> queue_type_t;
std::map<uint32_t, queue_type_t> _queues;
transport::zero_copy_if::sptr _xport;
- boost::mutex mutex;
+ std::mutex mutex;
};
struct recv_packet_demuxer_proxy_3000 : transport::zero_copy_if
diff --git a/host/lib/property_tree.cpp b/host/lib/property_tree.cpp
index 53268efd3..14d3ae8c4 100644
--- a/host/lib/property_tree.cpp
+++ b/host/lib/property_tree.cpp
@@ -8,9 +8,8 @@
#include <uhd/property_tree.hpp>
#include <uhd/types/dict.hpp>
-#include <boost/thread/mutex.hpp>
-#include <iostream>
#include <memory>
+#include <mutex>
using namespace uhd;
@@ -79,7 +78,7 @@ public:
sptr subtree(const fs_path& path_) const override
{
const fs_path path = _root / path_;
- boost::mutex::scoped_lock lock(_guts->mutex);
+ std::lock_guard<std::mutex> lock(_guts->mutex);
property_tree_impl* subtree = new property_tree_impl(path);
subtree->_guts = this->_guts; // copy the guts sptr
@@ -89,7 +88,7 @@ public:
void remove(const fs_path& path_) override
{
const fs_path path = _root / path_;
- boost::mutex::scoped_lock lock(_guts->mutex);
+ std::lock_guard<std::mutex> lock(_guts->mutex);
node_type* parent = NULL;
node_type* node = &_guts->root;
@@ -107,7 +106,7 @@ public:
bool exists(const fs_path& path_) const override
{
const fs_path path = _root / path_;
- boost::mutex::scoped_lock lock(_guts->mutex);
+ std::lock_guard<std::mutex> lock(_guts->mutex);
node_type* node = &_guts->root;
for (const std::string& name : path_tokenizer(path)) {
@@ -121,7 +120,7 @@ public:
std::vector<std::string> list(const fs_path& path_) const override
{
const fs_path path = _root / path_;
- boost::mutex::scoped_lock lock(_guts->mutex);
+ std::lock_guard<std::mutex> lock(_guts->mutex);
node_type* node = &_guts->root;
for (const std::string& name : path_tokenizer(path)) {
@@ -136,7 +135,7 @@ public:
std::shared_ptr<void> _pop(const fs_path& path_) override
{
const fs_path path = _root / path_;
- boost::mutex::scoped_lock lock(_guts->mutex);
+ std::lock_guard<std::mutex> lock(_guts->mutex);
node_type* parent = NULL;
node_type* node = &_guts->root;
@@ -159,7 +158,7 @@ public:
void _create(const fs_path& path_, const std::shared_ptr<void>& prop) override
{
const fs_path path = _root / path_;
- boost::mutex::scoped_lock lock(_guts->mutex);
+ std::lock_guard<std::mutex> lock(_guts->mutex);
node_type* node = &_guts->root;
for (const std::string& name : path_tokenizer(path)) {
@@ -176,7 +175,7 @@ public:
std::shared_ptr<void>& _access(const fs_path& path_) const override
{
const fs_path path = _root / path_;
- boost::mutex::scoped_lock lock(_guts->mutex);
+ std::lock_guard<std::mutex> lock(_guts->mutex);
node_type* node = &_guts->root;
for (const std::string& name : path_tokenizer(path)) {
@@ -205,7 +204,7 @@ private:
struct tree_guts_type
{
node_type root;
- boost::mutex mutex;
+ std::mutex mutex;
};
// members, the tree and root prefix
diff --git a/host/lib/transport/libusb1_base.cpp b/host/lib/transport/libusb1_base.cpp
index df6ed45eb..6808a3e0d 100644
--- a/host/lib/transport/libusb1_base.cpp
+++ b/host/lib/transport/libusb1_base.cpp
@@ -11,7 +11,6 @@
#include <uhd/types/serial.hpp>
#include <uhd/utils/log.hpp>
#include <uhd/utils/tasks.hpp>
-#include <boost/thread/mutex.hpp>
#include <cstdlib>
#include <functional>
#include <iostream>
@@ -353,8 +352,8 @@ libusb::device_handle::sptr libusb::device_handle::get_cached_handle(device::spt
static uhd::dict<libusb_device*, std::weak_ptr<device_handle>> handles;
// lock for atomic access to static table above
- static boost::mutex mutex;
- boost::mutex::scoped_lock lock(mutex);
+ static std::mutex mutex;
+ std::lock_guard<std::mutex> lock(mutex);
// not expired -> get existing handle
if (handles.has_key(dev->get()) and not handles[dev->get()].expired()) {
diff --git a/host/lib/transport/libusb1_control.cpp b/host/lib/transport/libusb1_control.cpp
index e6339e17f..5d49e3931 100644
--- a/host/lib/transport/libusb1_control.cpp
+++ b/host/lib/transport/libusb1_control.cpp
@@ -7,7 +7,7 @@
#include "libusb1_base.hpp"
#include <uhd/transport/usb_control.hpp>
-#include <boost/thread/mutex.hpp>
+#include <mutex>
using namespace uhd::transport;
@@ -38,7 +38,7 @@ public:
uint16_t length,
uint32_t libusb_timeout = 0) override
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
return libusb_control_transfer(_handle->get(),
request_type,
request,
@@ -51,7 +51,7 @@ public:
private:
libusb::device_handle::sptr _handle;
- boost::mutex _mutex;
+ std::mutex _mutex;
};
libusb_control_impl::~libusb_control_impl(void)
diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp
index fc36b36b7..fe33d2068 100644
--- a/host/lib/transport/libusb1_zero_copy.cpp
+++ b/host/lib/transport/libusb1_zero_copy.cpp
@@ -14,11 +14,11 @@
#include <uhd/utils/log.hpp>
#include <boost/circular_buffer.hpp>
#include <boost/format.hpp>
-#include <boost/thread/condition_variable.hpp>
-#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
#include <functional>
#include <list>
#include <memory>
+#include <mutex>
using namespace uhd;
using namespace uhd::transport;
@@ -49,8 +49,8 @@ struct lut_result_t
int completed;
libusb_transfer_status status;
int actual_length;
- boost::mutex mut;
- boost::condition_variable usb_transfer_complete;
+ std::mutex mut;
+ boost::condition usb_transfer_complete;
#ifdef UHD_TXRX_DEBUG_PRINTS
// These are fore debugging
@@ -89,7 +89,7 @@ static void libusb1_zerocopy_dbg_print_err(std::string msg)
static void LIBUSB_CALL libusb_async_cb(libusb_transfer* lut)
{
lut_result_t* r = (lut_result_t*)lut->user_data;
- boost::lock_guard<boost::mutex> lock(r->mut);
+ std::lock_guard<std::mutex> lock(r->mut);
r->status = lut->status;
r->actual_length = lut->actual_length;
r->completed = 1;
@@ -179,7 +179,7 @@ public:
*/
UHD_INLINE bool wait_for_completion(const double timeout)
{
- boost::unique_lock<boost::mutex> lock(result.mut);
+ std::unique_lock<std::mutex> lock(result.mut);
if (!result.completed) {
if (timeout < 0.0) {
result.usb_transfer_complete.wait(lock);
@@ -313,9 +313,9 @@ public:
return buff;
// Serialize access to buffers
- boost::mutex::scoped_lock get_buff_lock(_get_buff_mutex);
+ std::lock_guard<std::mutex> get_buff_lock(_get_buff_mutex);
- boost::mutex::scoped_lock queue_lock(_queue_mutex);
+ std::unique_lock<std::mutex> queue_lock(_queue_mutex);
if (_enqueued.empty()) {
_buff_ready_cond.timed_wait(
queue_lock, boost::posix_time::microseconds(long(timeout * 1e6)));
@@ -351,9 +351,9 @@ private:
buffer_pool::sptr _buffer_pool;
std::vector<std::shared_ptr<libusb_zero_copy_mb>> _mb_pool;
- boost::mutex _queue_mutex;
- boost::condition_variable _buff_ready_cond;
- boost::mutex _get_buff_mutex;
+ std::mutex _queue_mutex;
+ boost::condition _buff_ready_cond;
+ std::mutex _get_buff_mutex;
//! why 2 queues? there is room in the future to have > N buffers but only N in flight
boost::circular_buffer<libusb_zero_copy_mb*> _enqueued, _released;
@@ -362,7 +362,7 @@ private:
void enqueue_buffer(libusb_zero_copy_mb* mb)
{
- boost::mutex::scoped_lock l(_queue_mutex);
+ std::lock_guard<std::mutex> l(_queue_mutex);
_released.push_back(mb);
this->submit_what_we_can();
_buff_ready_cond.notify_one();
@@ -416,13 +416,13 @@ struct libusb_zero_copy_impl : usb_zero_copy
managed_recv_buffer::sptr get_recv_buff(double timeout) override
{
- boost::mutex::scoped_lock l(_recv_mutex);
+ std::lock_guard<std::mutex> l(_recv_mutex);
return _recv_impl->get_buff<managed_recv_buffer>(timeout);
}
managed_send_buffer::sptr get_send_buff(double timeout) override
{
- boost::mutex::scoped_lock l(_send_mutex);
+ std::lock_guard<std::mutex> l(_send_mutex);
return _send_impl->get_buff<managed_send_buffer>(timeout);
}
@@ -445,7 +445,7 @@ struct libusb_zero_copy_impl : usb_zero_copy
}
std::shared_ptr<libusb_zero_copy_single> _recv_impl, _send_impl;
- boost::mutex _recv_mutex, _send_mutex;
+ std::mutex _recv_mutex, _send_mutex;
};
libusb_zero_copy_impl::~libusb_zero_copy_impl(void)
diff --git a/host/lib/transport/muxed_zero_copy_if.cpp b/host/lib/transport/muxed_zero_copy_if.cpp
index f7cc88c9c..34407a9ff 100644
--- a/host/lib/transport/muxed_zero_copy_if.cpp
+++ b/host/lib/transport/muxed_zero_copy_if.cpp
@@ -10,10 +10,10 @@
#include <uhd/transport/muxed_zero_copy_if.hpp>
#include <uhd/utils/safe_call.hpp>
#include <boost/thread.hpp>
-#include <boost/thread/locks.hpp>
#include <functional>
#include <map>
#include <memory>
+#include <mutex>
using namespace uhd;
using namespace uhd::transport;
@@ -60,7 +60,7 @@ public:
zero_copy_if::sptr make_stream(const uint32_t stream_num) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
if (_streams.size() >= _max_num_streams) {
throw uhd::runtime_error("muxed_zero_copy_if: stream capacity exceeded. "
"cannot create more streams.");
@@ -82,7 +82,7 @@ public:
void remove_stream(const uint32_t stream_num) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
_streams.erase(stream_num);
}
@@ -256,7 +256,7 @@ private:
{
// Hold the stream mutex long enough to pull a bounded buffer
// and lock it (increment its ref count).
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
stream_map_t::iterator str_iter = _streams.find(stream_num);
if (str_iter != _streams.end()) {
stream = (*str_iter).second.lock();
@@ -270,7 +270,7 @@ private:
if (stream.get()) {
stream->push_recv_buff(buff);
} else {
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
_num_dropped_frames++;
}
// We processed a packet, and there could be more coming
@@ -291,7 +291,7 @@ private:
const size_t _max_num_streams;
size_t _num_dropped_frames;
boost::thread _recv_thread;
- boost::mutex _mutex;
+ std::mutex _mutex;
};
muxed_zero_copy_if::sptr muxed_zero_copy_if::make(zero_copy_if::sptr base_xport,
diff --git a/host/lib/transport/nirio/niusrprio_session.cpp b/host/lib/transport/nirio/niusrprio_session.cpp
index b2ea659df..00838075f 100644
--- a/host/lib/transport/nirio/niusrprio_session.cpp
+++ b/host/lib/transport/nirio/niusrprio_session.cpp
@@ -51,7 +51,7 @@ nirio_status niusrprio_session::enumerate(
nirio_status niusrprio_session::open(nifpga_lvbitx::sptr lvbitx, bool force_download)
{
- boost::unique_lock<boost::recursive_mutex> lock(_session_mutex);
+ std::unique_lock<std::recursive_mutex> lock(_session_mutex);
_lvbitx = lvbitx;
@@ -101,7 +101,7 @@ nirio_status niusrprio_session::open(nifpga_lvbitx::sptr lvbitx, bool force_down
void niusrprio_session::close(bool skip_reset)
{
- boost::unique_lock<boost::recursive_mutex> lock(_session_mutex);
+ std::unique_lock<std::recursive_mutex> lock(_session_mutex);
if (_session_open) {
nirio_status status = NiRio_Status_Success;
@@ -114,14 +114,14 @@ void niusrprio_session::close(bool skip_reset)
nirio_status niusrprio_session::reset()
{
- boost::unique_lock<boost::recursive_mutex> lock(_session_mutex);
+ std::unique_lock<std::recursive_mutex> lock(_session_mutex);
return _rpc_client.niusrprio_reset_device(_resource_name);
}
nirio_status niusrprio_session::download_bitstream_to_flash(
const std::string& bitstream_path)
{
- boost::unique_lock<boost::recursive_mutex> lock(_session_mutex);
+ std::unique_lock<std::recursive_mutex> lock(_session_mutex);
return _rpc_client.niusrprio_download_fpga_to_flash(_resource_name, bitstream_path);
}
diff --git a/host/lib/transport/nirio/rpc/rpc_client.cpp b/host/lib/transport/nirio/rpc/rpc_client.cpp
index 661f72e81..7b5970610 100644
--- a/host/lib/transport/nirio/rpc/rpc_client.cpp
+++ b/host/lib/transport/nirio/rpc/rpc_client.cpp
@@ -109,7 +109,7 @@ const boost::system::error_code& rpc_client::call(func_id_t func_id,
func_args_reader_t& out_args,
boost::posix_time::milliseconds timeout)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::unique_lock<std::mutex> lock(_mutex);
if (_io_service_thread.get()) {
_request.header.func_id = func_id;
@@ -168,7 +168,7 @@ const boost::system::error_code& rpc_client::call(func_id_t func_id,
void rpc_client::_handle_response_hdr(
const boost::system::error_code& err, size_t transferred, size_t expected)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
_exec_err = err;
if (!_exec_err && (transferred == expected)) {
// Response header received. Verify that it is expected
@@ -205,7 +205,7 @@ void rpc_client::_handle_response_hdr(
void rpc_client::_handle_response_data(
const boost::system::error_code& err, size_t transferred, size_t expected)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
_exec_err = err;
if (transferred != expected) {
_exec_err.assign(boost::asio::error::operation_aborted,
diff --git a/host/lib/transport/nirio_link.cpp b/host/lib/transport/nirio_link.cpp
index 28883ead0..b354aa377 100644
--- a/host/lib/transport/nirio_link.cpp
+++ b/host/lib/transport/nirio_link.cpp
@@ -9,6 +9,7 @@
#include <uhdlib/transport/adapter.hpp>
#include <uhdlib/transport/links.hpp>
#include <uhdlib/transport/nirio_link.hpp>
+#include <boost/format.hpp>
#include <chrono>
// X300 regs
diff --git a/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp b/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp
index b2348c3a9..7596b47be 100644
--- a/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp
+++ b/host/lib/usrp/b100/usb_zero_copy_wrapper.cpp
@@ -11,11 +11,10 @@
#include <uhd/utils/log.hpp>
#include <uhd/utils/tasks.hpp>
#include <uhdlib/utils/atomic.hpp>
-#include <boost/thread/condition_variable.hpp>
-#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
#include <functional>
-#include <iostream>
#include <memory>
+#include <mutex>
#include <vector>
using namespace uhd;
@@ -98,7 +97,7 @@ public:
void release(void) override
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::unique_lock<std::mutex> lock(_mutex);
_ok_to_auto_flush = true;
// get a reference to the VITA header before incrementing
@@ -124,7 +123,7 @@ public:
UHD_INLINE sptr get_new(const double timeout)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
_ok_to_auto_flush = false;
if (not _last_send_buff) {
@@ -146,8 +145,8 @@ private:
char* _mem_buffer_tip;
// private variables for auto flusher
- boost::mutex _mutex;
- boost::condition_variable _cond;
+ std::mutex _mutex;
+ boost::condition _cond;
uhd::task::sptr _task;
bool _ok_to_auto_flush;
@@ -157,7 +156,7 @@ private:
*/
void auto_flush(void)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::unique_lock<std::mutex> lock(_mutex);
const bool timeout = not _cond.timed_wait(lock, AUTOFLUSH_TIMEOUT);
if (timeout and _ok_to_auto_flush and _last_send_buff and _bytes_in_buffer != 0) {
_last_send_buff->commit(_bytes_in_buffer);
diff --git a/host/lib/usrp/b200/b200_radio_ctrl_core.cpp b/host/lib/usrp/b200/b200_radio_ctrl_core.cpp
index e885bf1b6..7a730b1fa 100644
--- a/host/lib/usrp/b200/b200_radio_ctrl_core.cpp
+++ b/host/lib/usrp/b200/b200_radio_ctrl_core.cpp
@@ -14,9 +14,8 @@
#include <uhd/utils/safe_call.hpp>
#include <uhdlib/usrp/common/async_packet_handler.hpp>
#include <boost/format.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/thread.hpp>
#include <functional>
+#include <mutex>
#include <queue>
using namespace uhd;
@@ -74,14 +73,14 @@ public:
******************************************************************/
void poke32(const wb_addr_type addr, const uint32_t data) override
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
this->send_pkt(addr / 4, data);
this->wait_for_ack(false);
}
uint32_t peek32(const wb_addr_type addr) override
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
this->send_pkt(SR_READBACK, addr / 8);
const uint64_t res = this->wait_for_ack(true);
const uint32_t lo = uint32_t(res & 0xffffffff);
@@ -91,7 +90,7 @@ public:
uint64_t peek64(const wb_addr_type addr) override
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
this->send_pkt(SR_READBACK, addr / 8);
return this->wait_for_ack(true);
}
@@ -101,7 +100,7 @@ public:
******************************************************************/
void set_time(const uhd::time_spec_t& time) override
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
_time = time;
_use_time = _time != uhd::time_spec_t(0.0);
if (_use_time)
@@ -110,13 +109,13 @@ public:
uhd::time_spec_t get_time(void) override
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
return _time;
}
void set_tick_rate(const double rate) override
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
_tick_rate = rate;
}
@@ -327,7 +326,7 @@ private:
uhd::msg_task::sptr _async_task;
const uint32_t _sid;
const std::string _name;
- boost::mutex _mutex;
+ std::mutex _mutex;
size_t _seq_out;
uhd::time_spec_t _time;
bool _use_time;
diff --git a/host/lib/usrp/common/recv_packet_demuxer.cpp b/host/lib/usrp/common/recv_packet_demuxer.cpp
index 9d3067286..9270a40bf 100644
--- a/host/lib/usrp/common/recv_packet_demuxer.cpp
+++ b/host/lib/usrp/common/recv_packet_demuxer.cpp
@@ -10,8 +10,8 @@
#include <uhd/utils/byteswap.hpp>
#include <uhd/utils/log.hpp>
#include <uhdlib/usrp/common/recv_packet_demuxer.hpp>
-#include <boost/thread/mutex.hpp>
#include <deque>
+#include <mutex>
#include <queue>
#include <vector>
@@ -59,7 +59,7 @@ public:
managed_recv_buffer::sptr get_recv_buff(
const size_t index, const double timeout) override
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
managed_recv_buffer::sptr buff;
// there is already an entry in the queue, so pop that
@@ -104,7 +104,7 @@ public:
private:
transport::zero_copy_if::sptr _transport;
const uint32_t _sid_base;
- boost::mutex _mutex;
+ std::mutex _mutex;
struct channel_guts_type
{
channel_guts_type(void) : wrapper(container) {}
diff --git a/host/lib/usrp/cores/i2c_core_200.cpp b/host/lib/usrp/cores/i2c_core_200.cpp
index 93e3fedf8..fd9332638 100644
--- a/host/lib/usrp/cores/i2c_core_200.cpp
+++ b/host/lib/usrp/cores/i2c_core_200.cpp
@@ -8,8 +8,8 @@
#include <uhd/exception.hpp>
#include <uhd/utils/log.hpp>
#include <uhdlib/usrp/cores/i2c_core_200.hpp>
-#include <boost/thread/mutex.hpp>
#include <chrono>
+#include <mutex>
#include <thread>
#define REG_I2C_WR_PRESCALER_LO (1 << 3) | 0
@@ -137,13 +137,13 @@ private:
void poke(const size_t what, const uint8_t cmd)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
_iface->poke32(_base, (what << 8) | cmd);
}
uint8_t peek(const size_t what)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
_iface->poke32(_base, what << 8);
return uint8_t(_iface->peek32(_readback));
}
@@ -151,7 +151,7 @@ private:
wb_iface::sptr _iface;
const size_t _base;
const size_t _readback;
- boost::mutex _mutex;
+ std::mutex _mutex;
};
i2c_core_200::sptr i2c_core_200::make(
diff --git a/host/lib/usrp/cores/user_settings_core_3000.cpp b/host/lib/usrp/cores/user_settings_core_3000.cpp
index 9e04175c2..7293f9070 100644
--- a/host/lib/usrp/cores/user_settings_core_3000.cpp
+++ b/host/lib/usrp/cores/user_settings_core_3000.cpp
@@ -7,7 +7,7 @@
#include <uhd/exception.hpp>
#include <uhdlib/usrp/cores/user_settings_core_3000.hpp>
-#include <boost/thread/thread.hpp>
+#include <mutex>
using namespace uhd;
@@ -38,7 +38,7 @@ public:
if (offset % sizeof(uint64_t) != 0)
throw uhd::value_error("peek64: Incorrect address alignment");
- boost::unique_lock<boost::mutex> lock(_mutex);
+ std::unique_lock<std::mutex> lock(_mutex);
_iface->poke32(
REG_USER_RB_ADDR, offset >> 3); // Translate byte offset to 64-bit offset
return _iface->peek64(_rb_reg_addr);
@@ -49,7 +49,7 @@ public:
if (offset % sizeof(uint32_t) != 0)
throw uhd::value_error("poke32: Incorrect address alignment");
- boost::unique_lock<boost::mutex> lock(_mutex);
+ std::unique_lock<std::mutex> lock(_mutex);
_iface->poke32(
REG_USER_SR_ADDR, offset >> 2); // Translate byte offset to 64-bit offset
_iface->poke32(REG_USER_SR_DATA, value);
@@ -72,7 +72,7 @@ private:
wb_iface::sptr _iface;
const wb_addr_type _sr_base_addr;
const wb_addr_type _rb_reg_addr;
- boost::mutex _mutex;
+ std::mutex _mutex;
};
wb_iface::sptr user_settings_core_3000::make(
diff --git a/host/lib/usrp/dboard/db_ubx.cpp b/host/lib/usrp/dboard/db_ubx.cpp
index d36347b86..56d73bdab 100644
--- a/host/lib/usrp/dboard/db_ubx.cpp
+++ b/host/lib/usrp/dboard/db_ubx.cpp
@@ -21,12 +21,12 @@
#include <uhd/utils/static.hpp>
#include <uhdlib/usrp/common/max287x.hpp>
#include <boost/algorithm/string.hpp>
-#include <boost/math/special_functions/round.hpp>
-#include <boost/thread/mutex.hpp>
+#include <boost/format.hpp>
#include <chrono>
#include <functional>
#include <map>
#include <memory>
+#include <mutex>
#include <thread>
using namespace uhd;
@@ -595,14 +595,14 @@ private:
**********************************************************************/
void write_spi_reg(spi_dest_t dest, uint32_t value)
{
- boost::mutex::scoped_lock lock(_spi_mutex);
+ std::lock_guard<std::mutex> lock(_spi_mutex);
ROUTE_SPI(_iface, dest);
WRITE_SPI(_iface, value);
}
void write_spi_regs(spi_dest_t dest, std::vector<uint32_t> values)
{
- boost::mutex::scoped_lock lock(_spi_mutex);
+ std::lock_guard<std::mutex> lock(_spi_mutex);
ROUTE_SPI(_iface, dest);
for (uint32_t value : values)
WRITE_SPI(_iface, value);
@@ -759,7 +759,7 @@ private:
**********************************************************************/
sensor_value_t get_locked(const std::string& pll_name)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
assert_has(ubx_plls, pll_name, "ubx pll name");
if (pll_name == "TXLO") {
@@ -785,7 +785,7 @@ private:
// Set RX antennas
std::string set_rx_ant(const std::string& ant)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
// validate input
assert_has(ubx_rx_antennas, ant, "ubx rx antenna name");
@@ -819,7 +819,7 @@ private:
**********************************************************************/
double set_tx_gain(double gain)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
gain = ubx_tx_gain_range.clip(gain);
int attn_code = int(std::floor(gain * 2));
_ubx_tx_atten_val = ((attn_code & 0x3F) << 10);
@@ -834,7 +834,7 @@ private:
double set_rx_gain(double gain)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
gain = ubx_rx_gain_range.clip(gain);
int attn_code = int(std::floor(gain * 2));
_ubx_rx_atten_val = ((attn_code & 0x3F) << 10);
@@ -852,7 +852,7 @@ private:
**********************************************************************/
double set_tx_freq(double freq)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
double freq_lo1 = 0.0;
double freq_lo2 = 0.0;
double ref_freq = _iface->get_clock_rate(dboard_iface::UNIT_TX);
@@ -1000,7 +1000,7 @@ private:
double set_rx_freq(double freq)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
double freq_lo1 = 0.0;
double freq_lo2 = 0.0;
double ref_freq = _iface->get_clock_rate(dboard_iface::UNIT_RX);
@@ -1186,7 +1186,7 @@ private:
**********************************************************************/
void set_power_mode(std::string mode)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
if (mode == "performance") {
// performance mode attempts to reduce tuning and settling time
// as much as possible without adding noise.
@@ -1292,7 +1292,7 @@ private:
}
}();
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
for (const auto& lo : {_txlo1, _txlo2, _rxlo1, _rxlo2}) {
lo->set_auto_retune(enabled);
}
@@ -1302,8 +1302,8 @@ private:
* Variables
**********************************************************************/
dboard_iface::sptr _iface;
- boost::mutex _spi_mutex;
- boost::mutex _mutex;
+ std::mutex _spi_mutex;
+ std::mutex _mutex;
ubx_cpld_reg_t _cpld_reg;
uint32_t _prev_cpld_value;
std::map<ubx_gpio_field_id_t, ubx_gpio_field_info_t> _gpio_map;
diff --git a/host/lib/usrp/dboard/twinrx/twinrx_ctrl.cpp b/host/lib/usrp/dboard/twinrx/twinrx_ctrl.cpp
index 29ab194be..355d980ee 100644
--- a/host/lib/usrp/dboard/twinrx/twinrx_ctrl.cpp
+++ b/host/lib/usrp/dboard/twinrx/twinrx_ctrl.cpp
@@ -12,6 +12,8 @@
#include <uhdlib/usrp/common/adf435x.hpp>
#include <uhdlib/usrp/common/adf535x.hpp>
#include <uhdlib/utils/narrow.hpp>
+#include <boost/chrono.hpp>
+#include <boost/format.hpp>
#include <chrono>
#include <cmath>
#include <thread>
@@ -158,19 +160,19 @@ public:
~twinrx_ctrl_impl() override
{
- UHD_SAFE_CALL(boost::lock_guard<boost::mutex> lock(_mutex);
+ UHD_SAFE_CALL(std::lock_guard<std::mutex> lock(_mutex);
_gpio_iface->set_field(twinrx_gpio::FIELD_SWPS_EN, 0);)
}
void commit() override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
_commit();
}
void set_chan_enabled(channel_t ch, bool enabled, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
if (ch == CH1 or ch == BOTH) {
_cpld_regs->if0_reg3.set(rm::if0_reg3_t::IF1_IF2_EN_CH1, bool2bin(enabled));
_cpld_regs->if0_reg0.set(rm::if0_reg0_t::AMP_LO2_EN_CH1, bool2bin(enabled));
@@ -191,7 +193,7 @@ public:
void set_preamp1(channel_t ch, preamp_state_t value, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
if (ch == CH1 or ch == BOTH) {
_cpld_regs->rf0_reg1.set(
rm::rf0_reg1_t::SWPA1_CTL_CH1, bool2bin(value == PREAMP_HIGHBAND));
@@ -218,7 +220,7 @@ public:
void set_preamp2(channel_t ch, bool enabled, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
if (ch == CH1 or ch == BOTH) {
_cpld_regs->rf2_reg7.set(
rm::rf2_reg7_t::SWPA4_CTRL_CH1, bool2bin(not enabled));
@@ -236,7 +238,7 @@ public:
void set_lb_preamp_preselector(
channel_t ch, bool enabled, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
if (ch == CH1 or ch == BOTH) {
_cpld_regs->rf0_reg7.set(
rm::rf0_reg7_t::SWPA3_CTRL_CH1, bool2bin(not enabled));
@@ -251,7 +253,7 @@ public:
void set_signal_path(channel_t ch, signal_path_t path, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
if (ch == CH1 or ch == BOTH) {
_cpld_regs->rf2_reg2.set(
rm::rf2_reg2_t::SW11_CTRL_CH1, bool2bin(path == PATH_LOWBAND));
@@ -299,7 +301,7 @@ public:
void set_lb_preselector(
channel_t ch, preselector_path_t path, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
uint32_t sw7val = 0, sw8val = 0;
switch (path) {
case PRESEL_PATH1:
@@ -336,7 +338,7 @@ public:
void set_hb_preselector(
channel_t ch, preselector_path_t path, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
uint32_t sw9ch1val = 0, sw10ch1val = 0, sw9ch2val = 0, sw10ch2val = 0;
switch (path) {
case PRESEL_PATH1:
@@ -380,7 +382,7 @@ public:
void set_input_atten(channel_t ch, uint8_t atten, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
if (ch == CH1 or ch == BOTH) {
_cpld_regs->rf0_reg0.set(rm::rf0_reg0_t::ATTEN_IN_CH1, atten & 0x1F);
}
@@ -393,7 +395,7 @@ public:
void set_lb_atten(channel_t ch, uint8_t atten, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
if (ch == CH1 or ch == BOTH) {
_cpld_regs->rf2_reg0.set(rm::rf2_reg0_t::ATTEN_LB_CH1, atten & 0x1F);
}
@@ -406,7 +408,7 @@ public:
void set_hb_atten(channel_t ch, uint8_t atten, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
if (ch == CH1 or ch == BOTH) {
_cpld_regs->rf1_reg0.set(rm::rf1_reg0_t::ATTEN_HB_CH1, atten & 0x1F);
}
@@ -419,7 +421,7 @@ public:
void set_lo1_source(channel_t ch, lo_source_t source, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
if (ch == CH1 or ch == BOTH) {
_cpld_regs->rf1_reg5.set(
rm::rf1_reg5_t::SW14_CTRL_CH2, bool2bin(source != LO_COMPANION));
@@ -447,7 +449,7 @@ public:
void set_lo2_source(channel_t ch, lo_source_t source, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
if (ch == CH1 or ch == BOTH) {
_cpld_regs->if0_reg0.set(
rm::if0_reg0_t::SW19_CTRL_CH2, bool2bin(source == LO_COMPANION));
@@ -472,7 +474,7 @@ public:
void set_lo1_export_source(lo_export_source_t source, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
// SW22 may conflict with the cal switch but this attr takes priority and we
// assume that the cal switch is disabled (by disabling it!)
_set_cal_mode(CAL_DISABLED, source);
@@ -486,7 +488,7 @@ public:
void set_lo2_export_source(lo_export_source_t source, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
_cpld_regs->if0_reg7.set(
rm::if0_reg7_t::SW24_CTRL_CH2, bool2bin(source == LO_CH2_SYNTH));
_cpld_regs->if0_reg4.set(
@@ -501,7 +503,7 @@ public:
void set_antenna_mapping(antenna_mapping_t mapping, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
enum switch_path_t { CONNECT, TERM, EXPORT, IMPORT, SWAP };
switch_path_t path1, path2;
@@ -548,7 +550,7 @@ public:
void set_crossover_cal_mode(cal_mode_t cal_mode, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
if (_lo1_export == LO_CH1_SYNTH && cal_mode == CAL_CH2) {
throw uhd::runtime_error(
"cannot enable cal crossover on CH2 when LO1 in CH1 is exported");
@@ -565,7 +567,7 @@ public:
double set_lo1_synth_freq(channel_t ch, double freq, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
double coerced_freq = 0.0;
if (ch == CH1 or ch == BOTH) {
@@ -586,7 +588,7 @@ public:
double set_lo2_synth_freq(channel_t ch, double freq, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
double coerced_freq = 0.0;
if (ch == CH1 or ch == BOTH) {
@@ -605,7 +607,7 @@ public:
double set_lo1_charge_pump(channel_t ch, double current, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
double coerced_current = 0.0;
if (ch == CH1 or ch == BOTH) {
coerced_current =
@@ -624,7 +626,7 @@ public:
double set_lo2_charge_pump(channel_t ch, double current, bool commit = true) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
double coerced_current = 0.0;
if (ch == CH1 or ch == BOTH) {
coerced_current =
@@ -655,7 +657,7 @@ public:
bool read_lo1_locked(channel_t ch) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
bool locked = true;
if (ch == CH1 or ch == BOTH) {
@@ -671,7 +673,7 @@ public:
bool read_lo2_locked(channel_t ch) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
bool locked = true;
if (ch == CH1 or ch == BOTH) {
@@ -851,7 +853,7 @@ private: // Members
}
};
- boost::mutex _mutex;
+ std::mutex _mutex;
dboard_iface::sptr _db_iface;
twinrx_gpio::sptr _gpio_iface;
twinrx_cpld_regmap::sptr _cpld_regs;
diff --git a/host/lib/usrp/dboard/twinrx/twinrx_io.hpp b/host/lib/usrp/dboard/twinrx/twinrx_io.hpp
index 538b0bfa8..5998a87d1 100644
--- a/host/lib/usrp/dboard/twinrx/twinrx_io.hpp
+++ b/host/lib/usrp/dboard/twinrx/twinrx_io.hpp
@@ -12,7 +12,7 @@
#include <uhd/usrp/dboard_base.hpp>
#include <uhd/utils/soft_register.hpp>
#include <uhdlib/usrp/cores/gpio_atr_3000.hpp>
-#include <boost/thread.hpp>
+#include <boost/chrono.hpp>
namespace uhd { namespace usrp { namespace dboard { namespace twinrx {
@@ -95,7 +95,7 @@ public:
void set_field(const uhd::soft_reg_field_t field, const uint32_t value)
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
using namespace soft_reg_field;
_db_iface->set_gpio_out(
@@ -104,7 +104,7 @@ public:
uint32_t get_field(const uhd::soft_reg_field_t field)
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
using namespace soft_reg_field;
return (_db_iface->read_gpio(dboard_iface::UNIT_BOTH) & mask<uint32_t>(field))
>> shift(field);
@@ -113,7 +113,7 @@ public:
// CPLD register write-only interface
void poke32(const wb_addr_type addr, const uint32_t data) override
{
- boost::lock_guard<boost::mutex> lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
using namespace soft_reg_field;
// Step 1: Write the reg offset and data to the GPIO bus and de-assert all enables
@@ -140,7 +140,7 @@ private: // Members/definitions
// Members
dboard_iface::sptr _db_iface;
- boost::mutex _mutex;
+ std::mutex _mutex;
};
class twinrx_cpld_regmap : public uhd::soft_regmap_t
diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp
index bcf938863..cafc2f662 100644
--- a/host/lib/usrp/gps_ctrl.cpp
+++ b/host/lib/usrp/gps_ctrl.cpp
@@ -12,12 +12,13 @@
#include <stdint.h>
#include <boost/algorithm/string.hpp>
#include <boost/date_time.hpp>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/format.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/thread.hpp>
+#include <boost/thread/thread_time.hpp>
#include <boost/tokenizer.hpp>
#include <chrono>
#include <ctime>
+#include <mutex>
#include <regex>
#include <string>
#include <thread>
@@ -49,7 +50,7 @@ class gps_ctrl_impl : public gps_ctrl
{
private:
std::map<std::string, std::tuple<std::string, boost::system_time, bool>> sentences;
- boost::mutex cache_mutex;
+ std::mutex cache_mutex;
boost::system_time _last_cache_update;
std::string get_sentence(const std::string which,
@@ -63,7 +64,7 @@ private:
boost::posix_time::time_duration age;
if (wait_for_next) {
- boost::lock_guard<boost::mutex> lock(cache_mutex);
+ std::lock_guard<std::mutex> lock(cache_mutex);
update_cache();
// mark sentence as touched
if (sentences.find(which) != sentences.end())
@@ -71,7 +72,7 @@ private:
}
while (1) {
try {
- boost::lock_guard<boost::mutex> lock(cache_mutex);
+ std::lock_guard<std::mutex> lock(cache_mutex);
// update cache if older than a millisecond
if (now - _last_cache_update > milliseconds(1)) {
diff --git a/host/lib/usrp/usrp1/soft_time_ctrl.cpp b/host/lib/usrp/usrp1/soft_time_ctrl.cpp
index 1c3015480..c23f572d0 100644
--- a/host/lib/usrp/usrp1/soft_time_ctrl.cpp
+++ b/host/lib/usrp/usrp1/soft_time_ctrl.cpp
@@ -8,8 +8,8 @@
#include "soft_time_ctrl.hpp"
#include <uhd/utils/tasks.hpp>
#include <uhdlib/utils/system_time.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/thread/condition_variable.hpp>
+#include <boost/thread/condition.hpp>
+#include <chrono>
#include <functional>
#include <iostream>
#include <memory>
@@ -52,13 +52,13 @@ public:
******************************************************************/
void set_time(const time_spec_t& time) override
{
- boost::mutex::scoped_lock lock(_update_mutex);
+ std::lock_guard<std::mutex> lock(_update_mutex);
_time_offset = uhd::get_system_time() - time;
}
time_spec_t get_time(void) override
{
- boost::mutex::scoped_lock lock(_update_mutex);
+ std::lock_guard<std::mutex> lock(_update_mutex);
return time_now();
}
@@ -69,11 +69,11 @@ public:
}
UHD_INLINE void sleep_until_time(
- boost::mutex::scoped_lock& lock, const time_spec_t& time)
+ std::unique_lock<std::mutex>& lock, const time_spec_t& time)
{
- boost::condition_variable cond;
+ boost::condition cond;
// use a condition variable to unlock, sleep, lock
- double seconds_to_sleep = (time - time_now()).get_real_secs();
+ const double seconds_to_sleep = (time - time_now()).get_real_secs();
cond.timed_wait(lock, pt::microseconds(long(seconds_to_sleep * 1e6)));
}
@@ -82,7 +82,7 @@ public:
******************************************************************/
size_t recv_post(rx_metadata_t& md, const size_t nsamps) override
{
- boost::mutex::scoped_lock lock(_update_mutex);
+ std::lock_guard<std::mutex> lock(_update_mutex);
// Since it timed out on the receive, check for inline messages...
// Must do a post check because recv() will not wake up for a message.
@@ -144,7 +144,7 @@ public:
if (not md.has_time_spec)
return;
- boost::mutex::scoped_lock lock(_update_mutex);
+ std::unique_lock<std::mutex> lock(_update_mutex);
time_spec_t time_at(md.time_spec - TWIDDLE);
@@ -168,7 +168,7 @@ public:
******************************************************************/
void recv_cmd_handle_cmd(const stream_cmd_t& cmd)
{
- boost::mutex::scoped_lock lock(_update_mutex);
+ std::unique_lock<std::mutex> lock(_update_mutex);
// handle the stream at time by sleeping
if (not cmd.stream_now) {
@@ -227,7 +227,7 @@ public:
}
private:
- boost::mutex _update_mutex;
+ std::mutex _update_mutex;
size_t _nsamps_remaining;
stream_cmd_t::stream_mode_t _stream_mode;
time_spec_t _time_offset;
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp
index 792b4721b..a966f91ea 100644
--- a/host/lib/usrp/usrp2/io_impl.cpp
+++ b/host/lib/usrp/usrp2/io_impl.cpp
@@ -92,7 +92,7 @@ public:
*/
UHD_INLINE bool check_fc_condition(double timeout)
{
- boost::mutex::scoped_lock lock(_fc_mutex);
+ std::unique_lock<std::mutex> lock(_fc_mutex);
if (this->ready())
return true;
boost::this_thread::disable_interruption di; // disable because the wait can throw
@@ -105,7 +105,7 @@ public:
*/
UHD_INLINE void update_fc_condition(seq_type seq)
{
- boost::mutex::scoped_lock lock(_fc_mutex);
+ std::unique_lock<std::mutex> lock(_fc_mutex);
_last_seq_ack = seq;
lock.unlock();
_fc_cond.notify_one();
@@ -117,7 +117,7 @@ private:
return seq_type(_last_seq_out - _last_seq_ack) < _max_seqs_out;
}
- boost::mutex _fc_mutex;
+ std::mutex _fc_mutex;
boost::condition _fc_cond;
seq_type _last_seq_out, _last_seq_ack;
const seq_type _max_seqs_out;
diff --git a/host/lib/usrp/usrp2/usrp2_fifo_ctrl.cpp b/host/lib/usrp/usrp2/usrp2_fifo_ctrl.cpp
index 116051216..a4f46fca6 100644
--- a/host/lib/usrp/usrp2/usrp2_fifo_ctrl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_fifo_ctrl.cpp
@@ -12,9 +12,7 @@
#include <uhd/utils/log.hpp>
#include <uhd/utils/safe_call.hpp>
#include <boost/asio.hpp> //htonl
-#include <boost/format.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/thread.hpp>
+#include <mutex>
using namespace uhd;
using namespace uhd::transport;
@@ -58,7 +56,7 @@ public:
******************************************************************/
void poke32(const wb_addr_type addr, const uint32_t data) override
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
this->send_pkt((addr - SETTING_REGS_BASE) / 4, data, POKE32_CMD);
@@ -67,7 +65,7 @@ public:
uint32_t peek32(const wb_addr_type addr) override
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
this->send_pkt((addr - READBACK_BASE) / 4, 0, PEEK32_CMD);
@@ -92,7 +90,7 @@ public:
******************************************************************/
void init_spi(void)
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
this->send_pkt(SPI_DIV, SPI_DIVIDER, POKE32_CMD);
this->wait_for_ack(_seq_out - MAX_SEQS_OUT);
@@ -106,7 +104,7 @@ public:
size_t num_bits,
bool readback) override
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
// load control word
uint32_t ctrl_word = 0;
@@ -145,7 +143,7 @@ public:
******************************************************************/
void set_time(const uhd::time_spec_t& time) override
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
_time = time;
_use_time = _time != uhd::time_spec_t(0.0);
if (_use_time)
@@ -154,13 +152,13 @@ public:
uhd::time_spec_t get_time() override
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
return _time;
}
void set_tick_rate(const double rate) override
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
_tick_rate = rate;
}
@@ -234,7 +232,7 @@ private:
}
zero_copy_if::sptr _xport;
- boost::mutex _mutex;
+ std::mutex _mutex;
uint16_t _seq_out;
uint16_t _seq_ack;
uhd::time_spec_t _time;
diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp
index 23104d18f..c79ffccab 100644
--- a/host/lib/usrp/usrp2/usrp2_iface.cpp
+++ b/host/lib/usrp/usrp2/usrp2_iface.cpp
@@ -26,6 +26,7 @@
#include <chrono>
#include <functional>
#include <iostream>
+#include <mutex>
#include <thread>
using namespace uhd;
@@ -268,7 +269,7 @@ public:
uint32_t lo = USRP2_FW_COMPAT_NUM,
uint32_t hi = USRP2_FW_COMPAT_NUM)
{
- boost::mutex::scoped_lock lock(_ctrl_mutex);
+ std::lock_guard<std::mutex> lock(_ctrl_mutex);
for (size_t i = 0; i < CTRL_RECV_RETRIES; i++) {
try {
@@ -472,7 +473,7 @@ private:
udp_simple::sptr _ctrl_transport;
// used in send/recv
- boost::mutex _ctrl_mutex;
+ std::mutex _ctrl_mutex;
uint32_t _ctrl_seq_num;
uint32_t _protocol_compat;
diff --git a/host/lib/usrp/usrp_c.cpp b/host/lib/usrp/usrp_c.cpp
index bda9454b6..7b8f3f8a6 100644
--- a/host/lib/usrp/usrp_c.cpp
+++ b/host/lib/usrp/usrp_c.cpp
@@ -12,8 +12,8 @@
#include <uhd/usrp/usrp.h>
#include <uhd/utils/static.hpp>
#include <string.h>
-#include <boost/thread/mutex.hpp>
#include <map>
+#include <mutex>
/****************************************************************************
* Helpers
@@ -86,17 +86,17 @@ UHD_SINGLETON_FCN(usrp_ptrs, get_usrp_ptrs);
/****************************************************************************
* RX Streamer
***************************************************************************/
-static boost::mutex _rx_streamer_make_mutex;
+static std::mutex _rx_streamer_make_mutex;
uhd_error uhd_rx_streamer_make(uhd_rx_streamer_handle* h)
{
- UHD_SAFE_C(boost::mutex::scoped_lock lock(_rx_streamer_make_mutex);
+ UHD_SAFE_C(std::lock_guard<std::mutex> lock(_rx_streamer_make_mutex);
(*h) = new uhd_rx_streamer;)
}
-static boost::mutex _rx_streamer_free_mutex;
+static std::mutex _rx_streamer_free_mutex;
uhd_error uhd_rx_streamer_free(uhd_rx_streamer_handle* h)
{
- UHD_SAFE_C(boost::mutex::scoped_lock lock(_rx_streamer_free_mutex); delete (*h);
+ UHD_SAFE_C(std::lock_guard<std::mutex> lock(_rx_streamer_free_mutex); delete (*h);
(*h) = NULL;)
}
@@ -142,17 +142,17 @@ uhd_error uhd_rx_streamer_last_error(
/****************************************************************************
* TX Streamer
***************************************************************************/
-static boost::mutex _tx_streamer_make_mutex;
+static std::mutex _tx_streamer_make_mutex;
uhd_error uhd_tx_streamer_make(uhd_tx_streamer_handle* h)
{
- UHD_SAFE_C(boost::mutex::scoped_lock lock(_tx_streamer_make_mutex);
+ UHD_SAFE_C(std::lock_guard<std::mutex> lock(_tx_streamer_make_mutex);
(*h) = new uhd_tx_streamer;)
}
-static boost::mutex _tx_streamer_free_mutex;
+static std::mutex _tx_streamer_free_mutex;
uhd_error uhd_tx_streamer_free(uhd_tx_streamer_handle* h)
{
- UHD_SAFE_C(boost::mutex::scoped_lock lock(_tx_streamer_free_mutex); delete *h;
+ UHD_SAFE_C(std::lock_guard<std::mutex> lock(_tx_streamer_free_mutex); delete *h;
*h = NULL;)
}
@@ -199,11 +199,11 @@ uhd_error uhd_tx_streamer_last_error(
/****************************************************************************
* Generate / Destroy API calls
***************************************************************************/
-static boost::mutex _usrp_find_mutex;
+static std::mutex _usrp_find_mutex;
uhd_error uhd_usrp_find(const char* args, uhd_string_vector_handle* strings_out)
{
UHD_SAFE_C(
- boost::mutex::scoped_lock _lock(_usrp_find_mutex);
+ std::lock_guard<std::mutex> _lock(_usrp_find_mutex);
uhd::device_addrs_t devs =
uhd::device::find(std::string(args), uhd::device::USRP);
@@ -212,10 +212,10 @@ uhd_error uhd_usrp_find(const char* args, uhd_string_vector_handle* strings_out)
: devs) { (*strings_out)->string_vector_cpp.push_back(dev.to_string()); })
}
-static boost::mutex _usrp_make_mutex;
+static std::mutex _usrp_make_mutex;
uhd_error uhd_usrp_make(uhd_usrp_handle* h, const char* args)
{
- UHD_SAFE_C(boost::mutex::scoped_lock lock(_usrp_make_mutex);
+ UHD_SAFE_C(std::lock_guard<std::mutex> lock(_usrp_make_mutex);
size_t usrp_count = usrp_ptr::usrp_counter;
usrp_ptr::usrp_counter++;
@@ -233,11 +233,11 @@ uhd_error uhd_usrp_make(uhd_usrp_handle* h, const char* args)
(*h)->usrp_index = usrp_count;)
}
-static boost::mutex _usrp_free_mutex;
+static std::mutex _usrp_free_mutex;
uhd_error uhd_usrp_free(uhd_usrp_handle* h)
{
UHD_SAFE_C(
- boost::mutex::scoped_lock lock(_usrp_free_mutex);
+ std::lock_guard<std::mutex> lock(_usrp_free_mutex);
if (!get_usrp_ptrs().count((*h)->usrp_index)) { return UHD_ERROR_INVALID_DEVICE; }
@@ -253,12 +253,12 @@ uhd_error uhd_usrp_last_error(uhd_usrp_handle h, char* error_out, size_t strbuff
strncpy(error_out, h->last_error.c_str(), strbuffer_len);)
}
-static boost::mutex _usrp_get_rx_stream_mutex;
+static std::mutex _usrp_get_rx_stream_mutex;
uhd_error uhd_usrp_get_rx_stream(
uhd_usrp_handle h_u, uhd_stream_args_t* stream_args, uhd_rx_streamer_handle h_s)
{
UHD_SAFE_C_SAVE_ERROR(
- h_s, boost::mutex::scoped_lock lock(_usrp_get_rx_stream_mutex);
+ h_s, std::lock_guard<std::mutex> lock(_usrp_get_rx_stream_mutex);
if (!get_usrp_ptrs().count(h_u->usrp_index)) {
h_s->last_error = "Streamer's device is invalid or expired.";
@@ -270,12 +270,12 @@ uhd_error uhd_usrp_get_rx_stream(
h_s->usrp_index = h_u->usrp_index;)
}
-static boost::mutex _usrp_get_tx_stream_mutex;
+static std::mutex _usrp_get_tx_stream_mutex;
uhd_error uhd_usrp_get_tx_stream(
uhd_usrp_handle h_u, uhd_stream_args_t* stream_args, uhd_tx_streamer_handle h_s)
{
UHD_SAFE_C_SAVE_ERROR(
- h_s, boost::mutex::scoped_lock lock(_usrp_get_tx_stream_mutex);
+ h_s, std::lock_guard<std::mutex> lock(_usrp_get_tx_stream_mutex);
if (!get_usrp_ptrs().count(h_u->usrp_index)) {
h_s->last_error = "Streamer's device is invalid or expired.";
diff --git a/host/lib/usrp/x300/x300_fw_ctrl.cpp b/host/lib/usrp/x300/x300_fw_ctrl.cpp
index 9cbad7576..110025228 100644
--- a/host/lib/usrp/x300/x300_fw_ctrl.cpp
+++ b/host/lib/usrp/x300/x300_fw_ctrl.cpp
@@ -16,8 +16,8 @@
#include <uhd/utils/log.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/format.hpp>
-#include <boost/thread/mutex.hpp>
#include <chrono>
+#include <mutex>
#include <thread>
using namespace uhd;
@@ -35,14 +35,14 @@ public:
void flush(void)
{
- boost::mutex::scoped_lock lock(reg_access);
+ std::lock_guard<std::mutex> lock(reg_access);
__flush();
}
void poke32(const wb_addr_type addr, const uint32_t data) override
{
for (size_t i = 1; i <= num_retries; i++) {
- boost::mutex::scoped_lock lock(reg_access);
+ std::lock_guard<std::mutex> lock(reg_access);
try {
return this->__poke32(addr, data);
} catch (const uhd::io_error& ex) {
@@ -60,7 +60,7 @@ public:
uint32_t peek32(const wb_addr_type addr) override
{
for (size_t i = 1; i <= num_retries; i++) {
- boost::mutex::scoped_lock lock(reg_access);
+ std::lock_guard<std::mutex> lock(reg_access);
try {
uint32_t data = this->__peek32(addr);
return data;
@@ -85,7 +85,7 @@ protected:
virtual void __flush() = 0;
virtual std::string __loc_info() = 0;
- boost::mutex reg_access;
+ std::mutex reg_access;
};
diff --git a/host/lib/usrp/x300/x300_fw_uart.cpp b/host/lib/usrp/x300/x300_fw_uart.cpp
index 1bfc2a2e4..804a1a357 100644
--- a/host/lib/usrp/x300/x300_fw_uart.cpp
+++ b/host/lib/usrp/x300/x300_fw_uart.cpp
@@ -11,8 +11,8 @@
#include <uhd/types/serial.hpp>
#include <uhd/types/wb_iface.hpp>
#include <uhd/utils/log.hpp>
-#include <boost/format.hpp>
#include <chrono>
+#include <mutex>
using namespace uhd;
@@ -52,7 +52,7 @@ struct x300_uart_iface : uart_iface
void write_uart(const std::string& buff) override
{
- boost::mutex::scoped_lock lock(_write_mutex);
+ std::lock_guard<std::mutex> lock(_write_mutex);
for (const char ch : buff) {
this->putchar(ch);
}
@@ -120,7 +120,7 @@ struct x300_uart_iface : uart_iface
std::string read_uart(double timeout) override
{
- boost::mutex::scoped_lock lock(_read_mutex);
+ std::lock_guard<std::mutex> lock(_read_mutex);
const auto exit_time = std::chrono::steady_clock::now()
+ std::chrono::microseconds(int64_t(timeout * 1e6));
@@ -156,8 +156,8 @@ struct x300_uart_iface : uart_iface
uint32_t _last_device_rxoffset;
std::vector<uint32_t> _rxcache;
std::string _rxbuff;
- boost::mutex _read_mutex;
- boost::mutex _write_mutex;
+ std::mutex _read_mutex;
+ std::mutex _write_mutex;
};
uart_iface::sptr x300_make_uart_iface(wb_iface::sptr iface)
diff --git a/host/lib/usrp_clock/octoclock/octoclock_impl.hpp b/host/lib/usrp_clock/octoclock/octoclock_impl.hpp
index 86fd5342d..f469f2dff 100644
--- a/host/lib/usrp_clock/octoclock/octoclock_impl.hpp
+++ b/host/lib/usrp_clock/octoclock/octoclock_impl.hpp
@@ -17,8 +17,8 @@
#include <uhd/usrp/gps_ctrl.hpp>
#include <uhd/usrp/mboard_eeprom.hpp>
#include <uhd/usrp_clock/octoclock_eeprom.hpp>
-#include <boost/thread.hpp>
#include <memory>
+#include <mutex>
uhd::device_addrs_t octoclock_find(const uhd::device_addr_t& hint);
@@ -73,7 +73,7 @@ private:
std::string _get_images_help_message(const std::string& addr);
- boost::mutex _device_mutex;
+ std::mutex _device_mutex;
};
#endif /* INCLUDED_OCTOCLOCK_IMPL_HPP */
diff --git a/host/lib/usrp_clock/usrp_clock_c.cpp b/host/lib/usrp_clock/usrp_clock_c.cpp
index ea67c7e6e..c0408bc5e 100644
--- a/host/lib/usrp_clock/usrp_clock_c.cpp
+++ b/host/lib/usrp_clock/usrp_clock_c.cpp
@@ -11,8 +11,8 @@
#include <uhd/usrp_clock/usrp_clock.h>
#include <uhd/utils/static.hpp>
#include <string.h>
-#include <boost/thread/mutex.hpp>
#include <map>
+#include <mutex>
/****************************************************************************
* Registry / Pointer Management
@@ -42,11 +42,11 @@ UHD_SINGLETON_FCN(usrp_clock_ptrs, get_usrp_clock_ptrs);
/****************************************************************************
* Generate / Destroy API calls
***************************************************************************/
-static boost::mutex _usrp_clock_find_mutex;
+static std::mutex _usrp_clock_find_mutex;
uhd_error uhd_usrp_clock_find(const char* args, uhd_string_vector_t* devices_out)
{
UHD_SAFE_C(
- boost::mutex::scoped_lock lock(_usrp_clock_find_mutex);
+ std::lock_guard<std::mutex> lock(_usrp_clock_find_mutex);
uhd::device_addrs_t devs =
uhd::device::find(std::string(args), uhd::device::CLOCK);
@@ -55,10 +55,10 @@ uhd_error uhd_usrp_clock_find(const char* args, uhd_string_vector_t* devices_out
: devs) { devices_out->string_vector_cpp.push_back(dev.to_string()); })
}
-static boost::mutex _usrp_clock_make_mutex;
+static std::mutex _usrp_clock_make_mutex;
uhd_error uhd_usrp_clock_make(uhd_usrp_clock_handle* h, const char* args)
{
- UHD_SAFE_C(boost::mutex::scoped_lock lock(_usrp_clock_make_mutex);
+ UHD_SAFE_C(std::lock_guard<std::mutex> lock(_usrp_clock_make_mutex);
size_t usrp_clock_count = usrp_clock_ptr::usrp_clock_counter;
usrp_clock_ptr::usrp_clock_counter++;
@@ -76,10 +76,10 @@ uhd_error uhd_usrp_clock_make(uhd_usrp_clock_handle* h, const char* args)
(*h)->usrp_clock_index = usrp_clock_count;)
}
-static boost::mutex _usrp_clock_free_mutex;
+static std::mutex _usrp_clock_free_mutex;
uhd_error uhd_usrp_clock_free(uhd_usrp_clock_handle* h)
{
- UHD_SAFE_C(boost::mutex::scoped_lock lock(_usrp_clock_free_mutex);
+ UHD_SAFE_C(std::lock_guard<std::mutex> lock(_usrp_clock_free_mutex);
if (!get_usrp_clock_ptrs().count((*h)->usrp_clock_index)) {
return UHD_ERROR_INVALID_DEVICE;
diff --git a/host/lib/utils/tasks.cpp b/host/lib/utils/tasks.cpp
index 0eddd2488..95219cb0c 100644
--- a/host/lib/utils/tasks.cpp
+++ b/host/lib/utils/tasks.cpp
@@ -16,6 +16,7 @@
#include <exception>
#include <functional>
#include <iostream>
+#include <mutex>
#include <thread>
#include <vector>
@@ -106,7 +107,7 @@ public:
*/
msg_payload_t get_msg_from_dump_queue(uint32_t sid) override
{
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
msg_payload_t b;
for (size_t i = 0; i < _dump_queue.size(); i++) {
if (sid == _dump_queue[i].first) {
@@ -133,7 +134,7 @@ private:
* pushed to the dump_queue. This way ctrl_cores can check dump_queue
* for missing messages.
*/
- boost::mutex::scoped_lock lock(_mutex);
+ std::lock_guard<std::mutex> lock(_mutex);
_dump_queue.push_back(buff.get());
}
}
@@ -155,7 +156,7 @@ private:
<< "The task loop will now exit, things may not work." << msg;
}
- boost::mutex _mutex;
+ std::mutex _mutex;
boost::thread_group _thread_group;
boost::barrier _spawn_barrier;
bool _running;