https://bugs.gentoo.org/946495 https://github.com/prusa3d/PrusaSlicer/issues/13799 diff '--color=auto' -urNp PrusaSlicer-version_2.8.1-orig/src/libslic3r/GCodeSender.cpp PrusaSlicer-version_2.8.1-dwok/src/libslic3r/GCodeSender.cpp --- PrusaSlicer-version_2.8.1-orig/src/libslic3r/GCodeSender.cpp 2024-12-21 11:52:03.612595066 +0100 +++ PrusaSlicer-version_2.8.1-dwok/src/libslic3r/GCodeSender.cpp 2024-12-21 12:34:03.859507724 +0100 @@ -113,7 +113,7 @@ GCodeSender::connect(std::string devname this->io.post(boost::bind(&GCodeSender::do_read, this)); // start reading in the background thread - boost::thread t(boost::bind(&boost::asio::io_service::run, &this->io)); + boost::thread t(boost::bind(&boost::asio::io_context::run, &this->io)); this->background_thread.swap(t); // always send a M105 to check for connection because firmware might be silent on connect diff '--color=auto' -urNp PrusaSlicer-version_2.8.1-orig/src/libslic3r/GCodeSender.hpp PrusaSlicer-version_2.8.1-dwok/src/libslic3r/GCodeSender.hpp --- PrusaSlicer-version_2.8.1-orig/src/libslic3r/GCodeSender.hpp 2024-12-21 11:52:03.612595066 +0100 +++ PrusaSlicer-version_2.8.1-dwok/src/libslic3r/GCodeSender.hpp 2024-12-21 12:34:26.163427521 +0100 @@ -40,7 +40,7 @@ class GCodeSender : private boost::nonco void reset(); private: - asio::io_service io; + asio::io_context io; asio::serial_port serial; boost::thread background_thread; boost::asio::streambuf read_buffer, write_buffer; diff '--color=auto' -urNp PrusaSlicer-version_2.8.1-orig/src/slic3r/GUI/FirmwareDialog.cpp PrusaSlicer-version_2.8.1-dwok/src/slic3r/GUI/FirmwareDialog.cpp --- PrusaSlicer-version_2.8.1-orig/src/slic3r/GUI/FirmwareDialog.cpp 2024-12-21 11:52:03.632594994 +0100 +++ PrusaSlicer-version_2.8.1-dwok/src/slic3r/GUI/FirmwareDialog.cpp 2024-12-21 12:33:40.507591681 +0100 @@ -429,7 +429,7 @@ void FirmwareDialog::priv::avr109_wait_f void FirmwareDialog::priv::avr109_reboot(const SerialPortInfo &port) { - asio::io_service io; + asio::io_context io; Serial serial(io, port.port, 1200); std::this_thread::sleep_for(std::chrono::milliseconds(50)); } diff '--color=auto' -urNp PrusaSlicer-version_2.8.1-orig/src/slic3r/Utils/Bonjour.cpp PrusaSlicer-version_2.8.1-dwok/src/slic3r/Utils/Bonjour.cpp --- PrusaSlicer-version_2.8.1-orig/src/slic3r/Utils/Bonjour.cpp 2024-12-21 11:52:03.644594950 +0100 +++ PrusaSlicer-version_2.8.1-dwok/src/slic3r/Utils/Bonjour.cpp 2024-12-21 12:47:16.560667015 +0100 @@ -624,11 +624,11 @@ UdpSession::UdpSession(Bonjour::ReplyFn buffer.resize(DnsMessage::MAX_SIZE); } -UdpSocket::UdpSocket( Bonjour::ReplyFn replyfn, const asio::ip::address& multicast_address, const asio::ip::address& interface_address, std::shared_ptr< boost::asio::io_service > io_service) +UdpSocket::UdpSocket( Bonjour::ReplyFn replyfn, const asio::ip::address& multicast_address, const asio::ip::address& interface_address, std::shared_ptr< boost::asio::io_context > io_context) : replyfn(replyfn) , multicast_address(multicast_address) - , socket(*io_service) - , io_service(io_service) + , socket(*io_context) + , io_context(io_context) { try { // open socket @@ -658,11 +658,11 @@ UdpSocket::UdpSocket( Bonjour::ReplyFn r } -UdpSocket::UdpSocket( Bonjour::ReplyFn replyfn, const asio::ip::address& multicast_address, std::shared_ptr< boost::asio::io_service > io_service) +UdpSocket::UdpSocket( Bonjour::ReplyFn replyfn, const asio::ip::address& multicast_address, std::shared_ptr< boost::asio::io_context > io_context) : replyfn(replyfn) , multicast_address(multicast_address) - , socket(*io_service) - , io_service(io_service) + , socket(*io_context) + , io_context(io_context) { try { // open socket @@ -714,7 +714,7 @@ void UdpSocket::receive_handler(SharedSe // let io_service to handle the datagram on session // from boost documentation io_service::post: // The io_service guarantees that the handler will only be called in a thread in which the run(), run_one(), poll() or poll_one() member functions is currently being invoked. - io_service->post(boost::bind(&UdpSession::handle_receive, session, error, bytes)); + boost::asio::post(*io_context, boost::bind(&UdpSession::handle_receive, session, error, bytes)); // immediately accept new datagrams async_receive(); } @@ -871,13 +871,13 @@ void Bonjour::priv::lookup_perform() { service_dn = (boost::format("_%1%._%2%.local") % service % protocol).str(); - std::shared_ptr< boost::asio::io_service > io_service(new boost::asio::io_service); + std::shared_ptr< boost::asio::io_context > io_context(new boost::asio::io_context); std::vector sockets; // resolve intefaces - from PR#6646 std::vector interfaces; - asio::ip::udp::resolver resolver(*io_service); + asio::ip::udp::resolver resolver(*io_context); boost::system::error_code ec; // ipv4 interfaces auto results = resolver.resolve(udp::v4(), asio::ip::host_name(), "", ec); @@ -890,12 +890,12 @@ void Bonjour::priv::lookup_perform() // create ipv4 socket for each interface // each will send to querry to for both ipv4 and ipv6 for (const auto& intrfc : interfaces) - sockets.emplace_back(new LookupSocket(txt_keys, service, service_dn, protocol, replyfn, BonjourRequest::MCAST_IP4, intrfc, io_service)); + sockets.emplace_back(new LookupSocket(txt_keys, service, service_dn, protocol, replyfn, BonjourRequest::MCAST_IP4, intrfc, io_context)); } else { BOOST_LOG_TRIVIAL(info) << "Failed to resolve ipv4 interfaces: " << ec.message(); } if (sockets.empty()) - sockets.emplace_back(new LookupSocket(txt_keys, service, service_dn, protocol, replyfn, BonjourRequest::MCAST_IP4, io_service)); + sockets.emplace_back(new LookupSocket(txt_keys, service, service_dn, protocol, replyfn, BonjourRequest::MCAST_IP4, io_context)); // ipv6 interfaces interfaces.clear(); //udp::resolver::query query(host, PORT, boost::asio::ip::resolver_query_base::numeric_service); @@ -910,9 +910,9 @@ void Bonjour::priv::lookup_perform() // create ipv6 socket for each interface // each will send to querry to for both ipv4 and ipv6 for (const auto& intrfc : interfaces) - sockets.emplace_back(new LookupSocket(txt_keys, service, service_dn, protocol, replyfn, BonjourRequest::MCAST_IP6, intrfc, io_service)); + sockets.emplace_back(new LookupSocket(txt_keys, service, service_dn, protocol, replyfn, BonjourRequest::MCAST_IP6, intrfc, io_context)); if (interfaces.empty()) - sockets.emplace_back(new LookupSocket(txt_keys, service, service_dn, protocol, replyfn, BonjourRequest::MCAST_IP6, io_service)); + sockets.emplace_back(new LookupSocket(txt_keys, service, service_dn, protocol, replyfn, BonjourRequest::MCAST_IP6, io_context)); } else { BOOST_LOG_TRIVIAL(info)<< "Failed to resolve ipv6 interfaces: " << ec.message(); } @@ -923,13 +923,13 @@ void Bonjour::priv::lookup_perform() socket->send(); // timer settings - asio::deadline_timer timer(*io_service); + asio::deadline_timer timer(*io_context); retries--; std::function timer_handler = [&](const error_code& error) { // end if (retries == 0 || error) { // is this correct ending? - io_service->stop(); + io_context->stop(); if (completefn) { completefn(); } @@ -947,7 +947,7 @@ void Bonjour::priv::lookup_perform() timer.expires_from_now(boost::posix_time::seconds(timeout)); timer.async_wait(timer_handler); // start io_service, it will run until it has something to do - so in this case until stop is called in timer - io_service->run(); + io_context->run(); } catch (std::exception& e) { BOOST_LOG_TRIVIAL(error) << e.what(); @@ -966,12 +966,12 @@ void Bonjour::priv::resolve_perform() rpls.push_back(reply); }; - std::shared_ptr< boost::asio::io_service > io_service(new boost::asio::io_service); + std::shared_ptr< boost::asio::io_context > io_context(new boost::asio::io_context); std::vector sockets; // resolve interfaces - from PR#6646 std::vector interfaces; - asio::ip::udp::resolver resolver(*io_service); + asio::ip::udp::resolver resolver(*io_context); boost::system::error_code ec; // ipv4 interfaces auto results = resolver.resolve(udp::v4(), asio::ip::host_name(), "", ec); @@ -984,12 +984,12 @@ void Bonjour::priv::resolve_perform() // create ipv4 socket for each interface // each will send to querry to for both ipv4 and ipv6 for (const auto& intrfc : interfaces) - sockets.emplace_back(new ResolveSocket(hostname, reply_callback, BonjourRequest::MCAST_IP4, intrfc, io_service)); + sockets.emplace_back(new ResolveSocket(hostname, reply_callback, BonjourRequest::MCAST_IP4, intrfc, io_context)); } else { BOOST_LOG_TRIVIAL(info) << "Failed to resolve ipv4 interfaces: " << ec.message(); } if (sockets.empty()) - sockets.emplace_back(new ResolveSocket(hostname, reply_callback, BonjourRequest::MCAST_IP4, io_service)); + sockets.emplace_back(new ResolveSocket(hostname, reply_callback, BonjourRequest::MCAST_IP4, io_context)); // ipv6 interfaces interfaces.clear(); @@ -1003,9 +1003,9 @@ void Bonjour::priv::resolve_perform() // create ipv6 socket for each interface // each will send to querry to for both ipv4 and ipv6 for (const auto& intrfc : interfaces) - sockets.emplace_back(new ResolveSocket(hostname, reply_callback, BonjourRequest::MCAST_IP6, intrfc, io_service)); + sockets.emplace_back(new ResolveSocket(hostname, reply_callback, BonjourRequest::MCAST_IP6, intrfc, io_context)); if (interfaces.empty()) - sockets.emplace_back(new ResolveSocket(hostname, reply_callback, BonjourRequest::MCAST_IP6, io_service)); + sockets.emplace_back(new ResolveSocket(hostname, reply_callback, BonjourRequest::MCAST_IP6, io_context)); } else { BOOST_LOG_TRIVIAL(info) << "Failed to resolve ipv6 interfaces: " << ec.message(); } @@ -1016,14 +1016,14 @@ void Bonjour::priv::resolve_perform() socket->send(); // timer settings - asio::deadline_timer timer(*io_service); + asio::deadline_timer timer(*io_context); retries--; std::function timer_handler = [&](const error_code& error) { int replies_count = replies.size(); // end if (retries == 0 || error || replies_count > 0) { // is this correct ending? - io_service->stop(); + io_context->stop(); if (replies_count > 0 && resolvefn) { resolvefn(replies); } @@ -1041,7 +1041,7 @@ void Bonjour::priv::resolve_perform() timer.expires_from_now(boost::posix_time::seconds(timeout)); timer.async_wait(timer_handler); // start io_service, it will run until it has something to do - so in this case until stop is called in timer - io_service->run(); + io_context->run(); } catch (std::exception& e) { BOOST_LOG_TRIVIAL(error) << e.what(); diff '--color=auto' -urNp PrusaSlicer-version_2.8.1-orig/src/slic3r/Utils/Bonjour.hpp PrusaSlicer-version_2.8.1-dwok/src/slic3r/Utils/Bonjour.hpp --- PrusaSlicer-version_2.8.1-orig/src/slic3r/Utils/Bonjour.hpp 2024-12-21 11:52:03.644594950 +0100 +++ PrusaSlicer-version_2.8.1-dwok/src/slic3r/Utils/Bonjour.hpp 2024-12-21 12:23:16.573836269 +0100 @@ -155,11 +155,11 @@ public: UdpSocket(Bonjour::ReplyFn replyfn , const boost::asio::ip::address& multicast_address , const boost::asio::ip::address& interface_address - , std::shared_ptr< boost::asio::io_service > io_service); + , std::shared_ptr< boost::asio::io_context > io_context); UdpSocket(Bonjour::ReplyFn replyfn , const boost::asio::ip::address& multicast_address - , std::shared_ptr< boost::asio::io_service > io_service); + , std::shared_ptr< boost::asio::io_context > io_context); void send(); void async_receive(); @@ -172,7 +172,7 @@ protected: boost::asio::ip::address multicast_address; boost::asio::ip::udp::socket socket; boost::asio::ip::udp::endpoint mcast_endpoint; - std::shared_ptr< boost::asio::io_service > io_service; + std::shared_ptr< boost::asio::io_context > io_context; std::vector requests; }; @@ -186,8 +186,8 @@ public: , Bonjour::ReplyFn replyfn , const boost::asio::ip::address& multicast_address , const boost::asio::ip::address& interface_address - , std::shared_ptr< boost::asio::io_service > io_service) - : UdpSocket(replyfn, multicast_address, interface_address, io_service) + , std::shared_ptr< boost::asio::io_context > io_context) + : UdpSocket(replyfn, multicast_address, interface_address, io_context) , txt_keys(txt_keys) , service(service) , service_dn(service_dn) @@ -203,8 +203,8 @@ public: , std::string protocol , Bonjour::ReplyFn replyfn , const boost::asio::ip::address& multicast_address - , std::shared_ptr< boost::asio::io_service > io_service) - : UdpSocket(replyfn, multicast_address, io_service) + , std::shared_ptr< boost::asio::io_context > io_context) + : UdpSocket(replyfn, multicast_address, io_context) , txt_keys(txt_keys) , service(service) , service_dn(service_dn) @@ -241,8 +241,8 @@ public: , Bonjour::ReplyFn replyfn , const boost::asio::ip::address& multicast_address , const boost::asio::ip::address& interface_address - , std::shared_ptr< boost::asio::io_service > io_service) - : UdpSocket(replyfn, multicast_address, interface_address, io_service) + , std::shared_ptr< boost::asio::io_context > io_context) + : UdpSocket(replyfn, multicast_address, interface_address, io_context) , hostname(hostname) { @@ -253,8 +253,8 @@ public: ResolveSocket(const std::string& hostname , Bonjour::ReplyFn replyfn , const boost::asio::ip::address& multicast_address - , std::shared_ptr< boost::asio::io_service > io_service) - : UdpSocket(replyfn, multicast_address, io_service) + , std::shared_ptr< boost::asio::io_context > io_context) + : UdpSocket(replyfn, multicast_address, io_context) , hostname(hostname) { diff '--color=auto' -urNp PrusaSlicer-version_2.8.1-orig/src/slic3r/Utils/Serial.cpp PrusaSlicer-version_2.8.1-dwok/src/slic3r/Utils/Serial.cpp --- PrusaSlicer-version_2.8.1-orig/src/slic3r/Utils/Serial.cpp 2024-12-21 11:52:03.644594950 +0100 +++ PrusaSlicer-version_2.8.1-dwok/src/slic3r/Utils/Serial.cpp 2024-12-21 11:59:40.018945840 +0100 @@ -282,12 +282,12 @@ std::vector scan_serial_por namespace asio = boost::asio; using boost::system::error_code; -Serial::Serial(asio::io_service& io_service) : - asio::serial_port(io_service) +Serial::Serial(asio::io_context &io_context) : + asio::serial_port(io_context) {} -Serial::Serial(asio::io_service& io_service, const std::string &name, unsigned baud_rate) : - asio::serial_port(io_service, name) +Serial::Serial(asio::io_context &io_context, const std::string &name, unsigned baud_rate) : + asio::serial_port(io_context, name) { set_baud_rate(baud_rate); } @@ -390,19 +390,19 @@ void Serial::reset_line_num() bool Serial::read_line(unsigned timeout, std::string &line, error_code &ec) { - auto& io_service = + auto& io_context = #if BOOST_VERSION >= 107000 //FIXME this is most certainly wrong! (boost::asio::io_context&)this->get_executor().context(); #else this->get_io_service(); #endif - asio::deadline_timer timer(io_service); + asio::deadline_timer timer(io_context); char c = 0; bool fail = false; while (true) { - io_service.reset(); + io_context.reset(); asio::async_read(*this, boost::asio::buffer(&c, 1), [&](const error_code &read_ec, size_t size) { if (ec || size == 0) { @@ -423,7 +423,7 @@ bool Serial::read_line(unsigned timeout, }); } - io_service.run(); + io_context.run(); if (fail) { return false; diff '--color=auto' -urNp PrusaSlicer-version_2.8.1-orig/src/slic3r/Utils/Serial.hpp PrusaSlicer-version_2.8.1-dwok/src/slic3r/Utils/Serial.hpp --- PrusaSlicer-version_2.8.1-orig/src/slic3r/Utils/Serial.hpp 2024-12-21 11:52:03.644594950 +0100 +++ PrusaSlicer-version_2.8.1-dwok/src/slic3r/Utils/Serial.hpp 2024-12-21 11:55:33.283837413 +0100 @@ -43,8 +43,8 @@ extern std::vector scan class Serial : public boost::asio::serial_port { public: - Serial(boost::asio::io_service &io_service); - Serial(boost::asio::io_service &io_service, const std::string &name, unsigned baud_rate); + Serial(boost::asio::io_context &io_context); + Serial(boost::asio::io_context &io_context, const std::string &name, unsigned baud_rate); Serial(const Serial &) = delete; Serial &operator=(const Serial &) = delete; ~Serial(); diff '--color=auto' -urNp PrusaSlicer-version_2.8.1-orig/src/slic3r/Utils/TCPConsole.cpp PrusaSlicer-version_2.8.1-dwok/src/slic3r/Utils/TCPConsole.cpp --- PrusaSlicer-version_2.8.1-orig/src/slic3r/Utils/TCPConsole.cpp 2024-12-21 11:52:03.644594950 +0100 +++ PrusaSlicer-version_2.8.1-dwok/src/slic3r/Utils/TCPConsole.cpp 2024-12-21 13:00:56.377754763 +0100 @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -161,7 +162,7 @@ bool TCPConsole::run_queue() auto endpoints = m_resolver.resolve(m_host_name, m_port_name); - m_socket.async_connect(endpoints->endpoint(), + boost::asio::async_connect(m_socket, endpoints, boost::bind(&TCPConsole::handle_connect, this, boost::placeholders::_1) );