From eff78b92512cfe89675f2efd768ddacb2e93ec62 Mon Sep 17 00:00:00 2001 From: bakedsnake Date: Mon, 24 Aug 2026 15:59:05 +0200 Subject: [PATCH] Updates deprecated `asio::io_service` with `asio::io_context` Thought I would leave this here for documentation purposes at least. This makes the latest version able to build. ( latest commit ). --- --- a/src/libslic3r/GCodeSender.cpp +++ b/src/libslic3r/GCodeSender.cpp @@ -35,7 +35,9 @@ struct termios2 { speed_t c_ispeed; speed_t c_ospeed; }; +#ifndef BOTHER #define BOTHER CBAUDEX +#endif #endif @@ -97,12 +99,12 @@ GCodeSender::connect(std::string devname, unsigned int baud_rate) fs.open("serial.txt", std::fstream::out | std::fstream::trunc); #endif - // this gives some work to the io_service before it is started + // this gives some work to the io_context before it is started // (post() runs the supplied function in its thread) - this->io.post(boost::bind(&GCodeSender::do_read, this)); + boost::asio::post(this->io, boost::bind(&GCodeSender::do_read, this)); // start reading in the background thread - boost::thread t(boost::bind(&asio::io_service::run, &this->io)); + boost::thread t(boost::bind(&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 @@ -159,9 +161,8 @@ GCodeSender::disconnect() if (!this->open) return; this->open = false; this->connected = false; - this->io.post(boost::bind(&GCodeSender::do_close, this)); + boost::asio::post(this->io, boost::bind(&GCodeSender::do_close, this)); this->background_thread.join(); - this->io.reset(); /* if (this->error_status()) { throw(boost::system::system_error(boost::system::error_code(), @@ -444,7 +445,7 @@ GCodeSender::send(const std::string &line, bool priority) void GCodeSender::send() { - this->io.post(boost::bind(&GCodeSender::do_send, this)); + boost::asio::post(this->io, boost::bind(&GCodeSender::do_send, this)); } void --- a/src/libslic3r/GCodeSender.hpp +++ b/src/libslic3r/GCodeSender.hpp @@ -47,7 +47,7 @@ class GCodeSender : private boost::noncopyable { 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; --- a/Build.PL +++ b/Build.PL @@ -152,7 +152,7 @@ if (defined $ENV{BOOST_LIBRARYPATH}) { # In order to generate the -l switches we need to know how Boost libraries are named my $have_boost = 0; my $have_boost_optional = 0; -my @boost_libraries = qw(system thread filesystem); # we need these +my @boost_libraries = qw(thread filesystem); # we need these my @boost_optional_libraries = qw(nowide); # we need these, but if they aren't present we can deal # check without explicit lib path (works on Linux) if (! $mswin) {