Skip to content

Commit

Permalink
fix: support for upcoming Boost 1.87.0
Browse files Browse the repository at this point in the history
io_service was deprecated and replaced by io_context in 1.66.0[^1].
The upcoming Boost 1.87.0 will remove the deprecated API[^2].

[^1]: boostorg/asio@b60e92b
[^2]: boostorg/asio@ec0908c
  • Loading branch information
cho-m authored and mhx committed Nov 19, 2024
1 parent d4d4081 commit b14b3b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/tool/pager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <string_view>
#include <vector>

#include <boost/asio/io_service.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/process.hpp>

#include <dwarfs/os_access.h>
Expand Down Expand Up @@ -79,7 +79,7 @@ std::optional<pager_program> find_pager_program(os_access const& os) {
}

void show_in_pager(pager_program const& pager, std::string text) {
boost::asio::io_service ios;
boost::asio::io_context ios;
bp::child proc(pager.name.wstring(), bp::args(pager.args),
bp::std_in =
boost::asio::const_buffer(text.data(), text.size()),
Expand Down
12 changes: 6 additions & 6 deletions test/tools_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#endif
#endif

#include <boost/asio/io_service.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/process.hpp>

#include <fmt/format.h>
Expand Down Expand Up @@ -360,7 +360,7 @@ class subprocess {
: subprocess(nullptr, prog, std::forward<Args>(args)...) {}

template <subprocess_arg... Args>
subprocess(boost::asio::io_service& ios, std::filesystem::path const& prog,
subprocess(boost::asio::io_context& ios, std::filesystem::path const& prog,
Args&&... args)
: subprocess(&ios, prog, std::forward<Args>(args)...) {}

Expand All @@ -382,7 +382,7 @@ class subprocess {

void run() {
if (!ios_) {
throw std::runtime_error("processes with external io_service must be run "
throw std::runtime_error("processes with external io_context must be run "
"externally and then waited for");
}
ios_->run();
Expand Down Expand Up @@ -450,15 +450,15 @@ class subprocess {

private:
template <subprocess_arg... Args>
subprocess(boost::asio::io_service* ios, std::filesystem::path const& prog,
subprocess(boost::asio::io_context* ios, std::filesystem::path const& prog,
Args&&... args)
: prog_{prog} {
(append_arg(cmdline_, std::forward<Args>(args)), ...);

ignore_sigpipe();

if (!ios) {
ios_ = std::make_unique<boost::asio::io_service>();
ios_ = std::make_unique<boost::asio::io_context>();
ios = ios_.get();
}

Expand Down Expand Up @@ -492,7 +492,7 @@ class subprocess {
}

bp::child c_;
std::unique_ptr<boost::asio::io_service> ios_;
std::unique_ptr<boost::asio::io_context> ios_;
std::future<std::string> out_;
std::future<std::string> err_;
std::string outs_;
Expand Down

0 comments on commit b14b3b0

Please sign in to comment.