aboutsummaryrefslogtreecommitdiff
path: root/source/lib/control/src
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2023-09-06 18:36:44 +0200
committerFelix Morgner <felix.morgner@gmail.com>2023-09-06 18:36:44 +0200
commit17a3bb9337fd7e4a57354ed5359e449d5ab1388c (patch)
treedef6985c1f0c40456304f22e3b30aa17ca01e82b /source/lib/control/src
parent426d5ca456d03058b37afaf180b5a57c6da53adc (diff)
downloadwanda-17a3bb9337fd7e4a57354ed5359e449d5ab1388c.tar.xz
wanda-17a3bb9337fd7e4a57354ed5359e449d5ab1388c.zip
deps: switch from non-boost to boost asio
Diffstat (limited to 'source/lib/control/src')
-rw-r--r--source/lib/control/src/commander.cpp3
-rw-r--r--source/lib/control/src/connection.cpp16
-rw-r--r--source/lib/control/src/interface.cpp18
3 files changed, 23 insertions, 14 deletions
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))
{