diff --git a/conanfile.py b/conanfile.py index d5ee621b..d3dbd48f 100644 --- a/conanfile.py +++ b/conanfile.py @@ -63,7 +63,7 @@ def build_requirements(self): def requirements(self): self.requires("secp256k1/0.22.0", transitive_headers=True, transitive_libs=True) - self.requires("boost/1.86.0", transitive_headers=True, transitive_libs=True) + self.requires("boost/1.87.0", transitive_headers=True, transitive_libs=True) self.requires("fmt/11.0.2", transitive_headers=True, transitive_libs=True) self.requires("expected-lite/0.8.0", transitive_headers=True, transitive_libs=True) self.requires("ctre/3.9.0", transitive_headers=True, transitive_libs=True) diff --git a/include/kth/infrastructure/utility/asio.hpp b/include/kth/infrastructure/utility/asio.hpp index 5c68052a..023074b3 100644 --- a/include/kth/infrastructure/utility/asio.hpp +++ b/include/kth/infrastructure/utility/asio.hpp @@ -34,7 +34,7 @@ using time_point = steady_clock::time_point; #if ! defined(__EMSCRIPTEN__) using timer = ::asio::basic_waitable_timer; -using service = ::asio::io_service; +using service = ::asio::io_context; using address = ::asio::ip::address; using ipv4 = ::asio::ip::address_v4; using ipv6 = ::asio::ip::address_v6; @@ -44,10 +44,11 @@ using endpoint = ::asio::ip::tcp::endpoint; using socket = tcp::socket; using acceptor = tcp::acceptor; using resolver = tcp::resolver; -using query = tcp::resolver::query; -using iterator = tcp::resolver::iterator; +// using query = tcp::resolver::query; +// using iterator = tcp::resolver::iterator; -constexpr int max_connections = ::asio::socket_base::max_connections; +// constexpr int max_connections = ::asio::socket_base::max_connections; +constexpr int max_connections = 128; // Boost thread is used because of thread_specific_ptr limitation: // stackoverflow.com/q/22448022/1172329 diff --git a/include/kth/infrastructure/utility/threadpool.hpp b/include/kth/infrastructure/utility/threadpool.hpp index 915af74f..9fa7267d 100644 --- a/include/kth/infrastructure/utility/threadpool.hpp +++ b/include/kth/infrastructure/utility/threadpool.hpp @@ -99,7 +99,8 @@ class KI_API threadpool std::atomic size_; std::vector threads_; mutable upgrade_mutex threads_mutex_; - std::shared_ptr work_; + // std::shared_ptr work_; + boost::asio::executor_work_guard work_; mutable upgrade_mutex work_mutex_; }; diff --git a/include/kth/infrastructure/utility/work.hpp b/include/kth/infrastructure/utility/work.hpp index 90dd2f98..b23d0a00 100644 --- a/include/kth/infrastructure/utility/work.hpp +++ b/include/kth/infrastructure/utility/work.hpp @@ -53,7 +53,11 @@ class KI_API work template void concurrent(Handler&& handler, Args&&... args) { // Service post ensures the job does not execute in the current thread. - service_.post(BIND_HANDLER(handler, args)); + // service_.post(BIND_HANDLER(handler, args)); + boost::asio::post(service_, BIND_HANDLER(handler, args)); + + + ////service_.post(inject(BIND_HANDLER(handler, args), CONCURRENT, //// concurrent_)); } @@ -72,7 +76,12 @@ class KI_API work void unordered(Handler&& handler, Args&&... args) { // Use a strand wrapper to prevent concurrency and a service post // to deny ordering while ensuring execution on another thread. - service_.post(strand_.wrap(BIND_HANDLER(handler, args))); + // service_.post(strand_.wrap(BIND_HANDLER(handler, args))); + + boost::asio::post(service_, boost::asio::bind_executor(strand_, BIND_HANDLER(handler, args))); + + + ////service_.post(strand_.wrap(inject(BIND_HANDLER(handler, args), //// UNORDERED, unordered_))); } diff --git a/src/config/authority.cpp b/src/config/authority.cpp index 3ced4d10..152d4617 100644 --- a/src/config/authority.cpp +++ b/src/config/authority.cpp @@ -67,7 +67,8 @@ static asio::ipv6 to_ipv6(asio::ipv4 const& ipv4_address) { // Create an IPv6 mapped IPv4 address via serialization. auto const ipv6 = to_ipv6(ipv4_address.to_string()); - return asio::ipv6::from_string(ipv6); + // return asio::ipv6::from_string(ipv6); + return boost::asio::ip::make_address_v6(ipv6); } static @@ -236,7 +237,8 @@ std::istream& operator>>(std::istream& input, authority& argument) { std::string ip_address = ipv6 ? ipv6.to_string() : to_ipv6(ipv4.to_string()); #if ! defined(__EMSCRIPTEN__) - argument.ip_ = asio::ipv6::from_string(ip_address); + // argument.ip_ = asio::ipv6::from_string(ip_address); + argument.ip_ = boost::asio::ip::make_address_v6(ip_address); #endif if (port) { diff --git a/src/utility/threadpool.cpp b/src/utility/threadpool.cpp index 214037dc..35c8b704 100644 --- a/src/utility/threadpool.cpp +++ b/src/utility/threadpool.cpp @@ -59,8 +59,8 @@ void threadpool::spawn_once(thread_priority priority) { if ( ! work_) { work_mutex_.unlock_upgrade_and_lock(); //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - work_ = std::make_shared(service_); - + // work_ = std::make_shared(service_); + work_ = boost::asio::make_work_guard(service_); work_mutex_.unlock_and_lock_upgrade(); //----------------------------------------------------------------- }