Skip to content

Commit

Permalink
src: remove threadpool and use boost asio thread_pool
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFFFC0000 committed Feb 4, 2025
1 parent 90359e3 commit a369d77
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 522 deletions.
1 change: 0 additions & 1 deletion src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ set(common_sources
perf_timer.cpp
pruning.cpp
spawn.cpp
threadpool.cpp
updates.cpp
aligned.c
timings.cc
Expand Down
17 changes: 12 additions & 5 deletions src/common/dns_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,19 @@
#include <set>
#include <stdlib.h>
#include "include_base_utils.h"
#include "common/threadpool.h"
#include "crypto/crypto.h"
#include <boost/thread/mutex.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/optional.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/bind/bind.hpp>
#include <boost/asio/thread_pool.hpp>
#include <boost/asio/post.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <thread>

using namespace epee;

#undef MONERO_DEFAULT_LOG_CATEGORY
Expand Down Expand Up @@ -487,17 +494,17 @@ bool load_txt_records_from_dns(std::vector<std::string> &good_records, const std

// send all requests in parallel
std::deque<bool> avail(dns_urls.size(), false), valid(dns_urls.size(), false);
tools::threadpool& tpool = tools::threadpool::getInstanceForIO();
tools::threadpool::waiter waiter(tpool);
int threads = std::thread::hardware_concurrency();
boost::asio::thread_pool thread_pool(threads);
for (size_t n = 0; n < dns_urls.size(); ++n)
{
tpool.submit(&waiter,[n, dns_urls, &records, &avail, &valid](){
boost::asio::post(thread_pool, [n, dns_urls, &records, &avail, &valid](){
const auto res = tools::DNSResolver::instance().get_txt_record(dns_urls[n], avail[n], valid[n]);
for (const auto &s: res)
records[n].insert(s);
});
}
waiter.wait();
thread_pool.wait();

size_t cur_index = first_index;
do
Expand Down
180 changes: 0 additions & 180 deletions src/common/threadpool.cpp

This file was deleted.

107 changes: 0 additions & 107 deletions src/common/threadpool.h

This file was deleted.

Loading

0 comments on commit a369d77

Please sign in to comment.