diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2023-09-06 18:36:44 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2023-09-06 18:36:44 +0200 |
| commit | 17a3bb9337fd7e4a57354ed5359e449d5ab1388c (patch) | |
| tree | def6985c1f0c40456304f22e3b30aa17ca01e82b /source/lib | |
| parent | 426d5ca456d03058b37afaf180b5a57c6da53adc (diff) | |
| download | wanda-17a3bb9337fd7e4a57354ed5359e449d5ab1388c.tar.xz wanda-17a3bb9337fd7e4a57354ed5359e449d5ab1388c.zip | |
deps: switch from non-boost to boost asio
Diffstat (limited to 'source/lib')
| -rw-r--r-- | source/lib/control/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | source/lib/control/include/wanda/control/commander.hpp | 7 | ||||
| -rw-r--r-- | source/lib/control/include/wanda/control/connection.hpp | 12 | ||||
| -rw-r--r-- | source/lib/control/include/wanda/control/interface.hpp | 13 | ||||
| -rw-r--r-- | source/lib/control/src/commander.cpp | 3 | ||||
| -rw-r--r-- | source/lib/control/src/connection.cpp | 16 | ||||
| -rw-r--r-- | source/lib/control/src/interface.cpp | 18 |
7 files changed, 41 insertions, 29 deletions
diff --git a/source/lib/control/CMakeLists.txt b/source/lib/control/CMakeLists.txt index 6e95456..ce1a9da 100644 --- a/source/lib/control/CMakeLists.txt +++ b/source/lib/control/CMakeLists.txt @@ -33,7 +33,6 @@ target_link_libraries("wanda-${LIB_NAME}" PUBLIC "wanda::proto" "wanda::system" - "asio::asio" "spdlog::spdlog_header_only" ) diff --git a/source/lib/control/include/wanda/control/commander.hpp b/source/lib/control/include/wanda/control/commander.hpp index c993fc0..d7ca73d 100644 --- a/source/lib/control/include/wanda/control/commander.hpp +++ b/source/lib/control/include/wanda/control/commander.hpp @@ -5,7 +5,8 @@ #include "wanda/proto/command.hpp" #include "wanda/proto/message.hpp" -#include <asio.hpp> +#include <boost/asio/io_context.hpp> +#include <boost/asio/io_service.hpp> #include <filesystem> #include <memory> @@ -34,7 +35,7 @@ namespace wanda::control /** * @brief Construct a new commander */ - commander(asio::io_service & service, std::filesystem::path socket, listener & listener); + commander(boost::asio::io_context & service, std::filesystem::path socket, listener & listener); /** * @brief Start communication with the remote daemon endpoint @@ -55,7 +56,7 @@ namespace wanda::control void on_received(connection::pointer connection, proto::message message) override; private: - asio::io_service & m_service; + boost::asio::io_context & m_service; wanda::control::connection::protocol::endpoint m_endpoint; wanda::control::connection::protocol::socket m_socket; wanda::control::connection::pointer m_connection; diff --git a/source/lib/control/include/wanda/control/connection.hpp b/source/lib/control/include/wanda/control/connection.hpp index 1ca451d..0284fd7 100644 --- a/source/lib/control/include/wanda/control/connection.hpp +++ b/source/lib/control/include/wanda/control/connection.hpp @@ -4,7 +4,8 @@ #include "wanda/meta/keyed.hpp" #include "wanda/proto/message.hpp" -#include <asio.hpp> +#include <boost/asio/local/stream_protocol.hpp> +#include <boost/asio/streambuf.hpp> #include <istream> #include <memory> @@ -20,7 +21,7 @@ namespace wanda::control */ struct connection : meta::keyed<connection>, std::enable_shared_from_this<connection> { - using protocol = asio::local::stream_protocol; + using protocol = boost::asio::local::stream_protocol; using pointer = std::shared_ptr<connection>; /** @@ -47,7 +48,8 @@ namespace wanda::control * @internal * @brief Construct a new control connection object * - * @note This constructor is keyed on a private key type so it can only be constructed using the #wanda::make_connection factory + * @note This constructor is keyed on a private key type so it can only be constructed using the + * #wanda::make_connection factory */ connection(key, protocol::socket socket); @@ -96,8 +98,8 @@ namespace wanda::control void perform_read(); protocol::socket m_socket; - asio::streambuf m_in{}; - asio::streambuf m_out{}; + boost::asio::streambuf m_in{}; + boost::asio::streambuf m_out{}; std::istream m_input{&m_in}; std::ostream m_output{&m_out}; std::set<listener *> m_listeners{}; diff --git a/source/lib/control/include/wanda/control/interface.hpp b/source/lib/control/include/wanda/control/interface.hpp index 3dca85f..e895b68 100644 --- a/source/lib/control/include/wanda/control/interface.hpp +++ b/source/lib/control/include/wanda/control/interface.hpp @@ -11,7 +11,8 @@ #include "wanda/meta/keyed.hpp" #include "wanda/proto/command.hpp" -#include <asio.hpp> +#include <boost/asio/local/stream_protocol.hpp> +#include <boost/asio/io_context.hpp> #include <spdlog/spdlog.h> #include <cstddef> @@ -40,7 +41,7 @@ namespace wanda::control */ struct interface : connection::listener, meta::keyed<interface>, std::enable_shared_from_this<interface> { - using protocol = asio::local::stream_protocol; + using protocol = boost::asio::local::stream_protocol; using pointer = std::shared_ptr<interface>; /** @@ -57,7 +58,7 @@ namespace wanda::control * * @note This constructor is keyed on a private key type so it can only be constructed using the #wanda::make_interface factory */ - interface(key, asio::io_service & service, protocol::endpoint endpoint, listener & listener); + interface(key, boost::asio::io_context & service, protocol::endpoint endpoint, listener & listener); /** * @brief Start handling of controller connections @@ -75,9 +76,9 @@ namespace wanda::control private: void perform_accept(); - friend pointer make_interface(asio::io_service & service, std::filesystem::path file, interface::listener & listener); + friend pointer make_interface(boost::asio::io_context & service, std::filesystem::path file, interface::listener & listener); - asio::io_service & m_service; + boost::asio::io_context & m_service; protocol::endpoint m_endpoint; protocol::socket m_socket; protocol::acceptor m_acceptor; @@ -89,7 +90,7 @@ namespace wanda::control /** * @brief A factory to create new #interface instances */ - interface::pointer make_interface(asio::io_service & service, std::filesystem::path socket, interface::listener & listener); + interface::pointer make_interface(boost::asio::io_context & service, std::filesystem::path socket, interface::listener & listener); } // namespace wanda::control diff --git a/source/lib/control/src/commander.cpp b/source/lib/control/src/commander.cpp index 3db2c59..4490bb7 100644 --- a/source/lib/control/src/commander.cpp +++ b/source/lib/control/src/commander.cpp @@ -5,11 +5,12 @@ #include "wanda/std_ext/optional.hpp" #include "wanda/system/logging.hpp" +#include <boost/asio/io_context.hpp> #include <spdlog/fmt/ostr.h> namespace wanda::control { - commander::commander(asio::io_service & service, std::filesystem::path socket, listener & listener) + commander::commander(boost::asio::io_context & service, std::filesystem::path socket, listener & listener) : m_service{service} , m_endpoint{socket.string()} , m_socket{service} diff --git a/source/lib/control/src/connection.cpp b/source/lib/control/src/connection.cpp index 30fc8af..97f41dd 100644 --- a/source/lib/control/src/connection.cpp +++ b/source/lib/control/src/connection.cpp @@ -2,7 +2,11 @@ #include "wanda/proto/message.hpp" -#include <asio.hpp> +#include <boost/asio/completion_condition.hpp> +#include <boost/asio/read_until.hpp> +#include <boost/asio/write.hpp> +#include <boost/system/detail/error_code.hpp> +#include <boost/system/error_code.hpp> #include <limits> @@ -42,7 +46,7 @@ namespace wanda::control void connection::send(proto::message message) { m_output << message << '\n'; - asio::async_write(m_socket, m_out, asio::transfer_exactly(message.size() + 1), [that = shared_from_this(), this](auto const & error, auto const length) { + boost::asio::async_write(m_socket, m_out, boost::asio::transfer_exactly(message.size() + 1), [that = shared_from_this(), this](auto const & error, auto const length) { if (error) { // TODO: Handle error @@ -56,7 +60,9 @@ namespace wanda::control void connection::close() { - if (auto error = std::error_code{}; m_socket.cancel(error)) + auto error = boost::system::error_code{}; + + if (m_socket.cancel(error), error) { for (auto & listener : m_listeners) { @@ -64,7 +70,7 @@ namespace wanda::control } } - if (auto error = std::error_code{}; m_socket.close(error)) + if (m_socket.close(error), error) { for (auto & listener : m_listeners) { @@ -91,7 +97,7 @@ namespace wanda::control void connection::perform_read() { - asio::async_read_until(m_socket, m_in, '\n', [that = shared_from_this(), this](auto const & error, auto const length) { + boost::asio::async_read_until(m_socket, m_in, '\n', [that = shared_from_this(), this](auto const & error, auto const length) { if (error) { for (auto & listener : m_listeners) diff --git a/source/lib/control/src/interface.cpp b/source/lib/control/src/interface.cpp index b0c4dd2..3ebc55a 100644 --- a/source/lib/control/src/interface.cpp +++ b/source/lib/control/src/interface.cpp @@ -5,6 +5,8 @@ #include "wanda/system/logging.hpp" #include <spdlog/fmt/ostr.h> +#include <boost/system/error_code.hpp> +#include <boost/asio/error.hpp> #include <unistd.h> #include <algorithm> @@ -27,7 +29,7 @@ namespace wanda::control // 'interface' implementation - interface::interface(interface::key key, asio::io_service & service, interface::protocol::endpoint endpoint, listener & listener) + interface::interface(interface::key key, boost::asio::io_context & service, interface::protocol::endpoint endpoint, listener & listener) : keyed{key} , m_service{service} , m_endpoint{std::move(endpoint)} @@ -39,17 +41,17 @@ namespace wanda::control std::error_code interface::start() { - if (auto error = std::error_code{}; m_acceptor.open(m_endpoint.protocol(), error)) + if (auto error = boost::system::error_code{}; m_acceptor.open(m_endpoint.protocol(), error), error) { return error; } - if (auto error = std::error_code{}; m_acceptor.bind(m_endpoint, error)) + if (auto error = boost::system::error_code{}; m_acceptor.bind(m_endpoint, error), error) { return error; } - if (auto error = std::error_code{}; m_acceptor.listen(128, error)) + if (auto error = boost::system::error_code{}; m_acceptor.listen(128, error), error) { return error; } @@ -67,14 +69,14 @@ namespace wanda::control connection->close(); } - auto error = std::error_code{}; - return m_acceptor.close(error); + auto error = boost::system::error_code{}; + return m_acceptor.close(error), error; } void interface::perform_accept() { m_acceptor.async_accept(m_socket, [that = shared_from_this(), this](auto const & error) { - if (error && error != asio::error::operation_aborted) + if (error && error != boost::asio::error::operation_aborted) { system::get_logger()->error("failed to accept connection because '{}'", error.message()); } @@ -140,7 +142,7 @@ namespace wanda::control } } - interface::pointer make_interface(asio::io_service & service, std::filesystem::path socket, interface::listener & listener) + interface::pointer make_interface(boost::asio::io_context & service, std::filesystem::path socket, interface::listener & listener) { if (std::filesystem::exists(socket)) { |
