diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-07-20 10:57:20 -0700 |
---|---|---|
committer | Brent Stapleton <brent.stapleton@ettus.com> | 2018-07-31 10:05:03 -0700 |
commit | 491e28c956b69dce24c3c62b534070fa267940e6 (patch) | |
tree | b9916898885104ad374e220b576ecf087199854e /host | |
parent | 476b65f35e2871b78be118e7bfe15b9e08de41b6 (diff) | |
download | uhd-491e28c956b69dce24c3c62b534070fa267940e6.tar.gz uhd-491e28c956b69dce24c3c62b534070fa267940e6.tar.bz2 uhd-491e28c956b69dce24c3c62b534070fa267940e6.zip |
mpmd: Parallelize broadcast-finding
This will broadcast on all interfaces concurrently, instead of serially.
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/usrp/mpmd/mpmd_find.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/host/lib/usrp/mpmd/mpmd_find.cpp b/host/lib/usrp/mpmd/mpmd_find.cpp index b2471d30c..26230e396 100644 --- a/host/lib/usrp/mpmd/mpmd_find.cpp +++ b/host/lib/usrp/mpmd/mpmd_find.cpp @@ -13,6 +13,7 @@ #include <uhd/transport/if_addrs.hpp> #include <boost/algorithm/string.hpp> #include <boost/asio.hpp> +#include <future> using namespace uhd; using namespace uhd::mpmd; @@ -176,8 +177,16 @@ device_addrs_t mpmd_find_with_bcast(const device_addr_t& hint) device_addrs_t addrs; UHD_LOG_TRACE("MPMD FIND", "Broadcasting on all available interfaces to find MPM devices."); - for (const transport::if_addrs_t& if_addr : transport::get_if_addrs()) { - device_addrs_t reply_addrs = mpmd_find_with_addr(if_addr.bcast, hint); + std::vector<std::future<device_addrs_t>> task_list; + for (const auto& if_addr : transport::get_if_addrs()) { + task_list.emplace_back(std::async(std::launch::async, + [if_addr, hint](){ + return mpmd_find_with_addr(if_addr.bcast, hint); + } + )); + } + for (auto &task : task_list) { + auto reply_addrs = task.get(); addrs.insert(addrs.begin(), reply_addrs.begin(), reply_addrs.end()); } return addrs; |