aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2019-04-01 17:27:09 +0200
committerRiccardo Spagni <ric@spagni.net>2019-04-01 17:27:09 +0200
commitc994dc7ec02a846991808fe0ed25d72762f622f4 (patch)
tree8617d824302569bbe524fbc1c9a3a9155ae9b8df /src
parentMerge pull request #5305 (diff)
parentUse threadpool instead of new threads for DNS queries (diff)
downloadmonero-c994dc7ec02a846991808fe0ed25d72762f622f4.tar.xz
Merge pull request #5306
8a97563a Use threadpool instead of new threads for DNS queries (Howard Chu)
Diffstat (limited to 'src')
-rw-r--r--src/common/dns_utils.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/common/dns_utils.cpp b/src/common/dns_utils.cpp
index a341a8c81..1a1155c7c 100644
--- a/src/common/dns_utils.cpp
+++ b/src/common/dns_utils.cpp
@@ -32,9 +32,9 @@
#include <stdlib.h>
#include "include_base_utils.h"
+#include "common/threadpool.h"
#include <random>
#include <boost/thread/mutex.hpp>
-#include <boost/thread/thread.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/optional.hpp>
using namespace epee;
@@ -523,16 +523,16 @@ bool load_txt_records_from_dns(std::vector<std::string> &good_records, const std
size_t first_index = dis(gen);
// send all requests in parallel
- std::vector<boost::thread> threads(dns_urls.size());
std::deque<bool> avail(dns_urls.size(), false), valid(dns_urls.size(), false);
+ tools::threadpool& tpool = tools::threadpool::getInstance();
+ tools::threadpool::waiter waiter;
for (size_t n = 0; n < dns_urls.size(); ++n)
{
- threads[n] = boost::thread([n, dns_urls, &records, &avail, &valid](){
+ tpool.submit(&waiter,[n, dns_urls, &records, &avail, &valid](){
records[n] = tools::DNSResolver::instance().get_txt_record(dns_urls[n], avail[n], valid[n]);
});
}
- for (size_t n = 0; n < dns_urls.size(); ++n)
- threads[n].join();
+ waiter.wait(&tpool);
size_t cur_index = first_index;
do