From 491e28c956b69dce24c3c62b534070fa267940e6 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 20 Jul 2018 10:57:20 -0700 Subject: mpmd: Parallelize broadcast-finding This will broadcast on all interfaces concurrently, instead of serially. --- host/lib/usrp/mpmd/mpmd_find.cpp | 13 +++++++++++-- 1 file 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 #include #include +#include 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> 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; -- cgit v1.2.3