aboutsummaryrefslogtreecommitdiff
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
parent426d5ca456d03058b37afaf180b5a57c6da53adc (diff)
downloadwanda-17a3bb9337fd7e4a57354ed5359e449d5ab1388c.tar.xz
wanda-17a3bb9337fd7e4a57354ed5359e449d5ab1388c.zip
deps: switch from non-boost to boost asio
-rw-r--r--conanfile.py2
-rw-r--r--source/app/CMakeLists.txt6
-rw-r--r--source/app/src/wandac.cpp12
-rw-r--r--source/app/src/wandad.cpp7
-rw-r--r--source/lib/control/CMakeLists.txt1
-rw-r--r--source/lib/control/include/wanda/control/commander.hpp7
-rw-r--r--source/lib/control/include/wanda/control/connection.hpp12
-rw-r--r--source/lib/control/include/wanda/control/interface.hpp13
-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
11 files changed, 56 insertions, 41 deletions
diff --git a/conanfile.py b/conanfile.py
index f03b07f..9e89939 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -27,7 +27,6 @@ class Wanda(ConanFile):
)
exports_sources = ("source/*",)
requires = (
- "asio/[~1.28]",
"boost/[~1.83]",
"libjpeg-turbo/[~3.0]",
"libpng/[~1.6]",
@@ -44,6 +43,7 @@ class Wanda(ConanFile):
cmake.test(env="CTEST_OUTPUT_ON_FAILURE=1")
def configure(self):
+ self.options["boost"].asio_no_deprecated = True
self.options["boost"].header_only = True
self.options["fmt"].header_only = True
self.options["spdlog"].header_only = True
diff --git a/source/app/CMakeLists.txt b/source/app/CMakeLists.txt
index a567dd1..f2c69e8 100644
--- a/source/app/CMakeLists.txt
+++ b/source/app/CMakeLists.txt
@@ -2,7 +2,7 @@ include("CheckIPOSupported")
check_ipo_supported(RESULT "WANDA_IPO_SUPPORTED")
-find_package("asio")
+find_package("Boost")
find_package("lyra")
find_package("spdlog")
@@ -17,7 +17,7 @@ target_link_libraries("${PROJECT_NAME}c" PRIVATE
"wanda::proto"
"wanda::system"
- "asio::asio"
+ "Boost::boost"
"bfg::lyra"
"spdlog::spdlog_header_only"
)
@@ -42,7 +42,7 @@ target_link_libraries("wandad" PRIVATE
"wanda::std_ext"
"wanda::system"
- "asio::asio"
+ "Boost::boost"
"bfg::lyra"
"spdlog::spdlog_header_only"
)
diff --git a/source/app/src/wandac.cpp b/source/app/src/wandac.cpp
index ae24d0f..ff27e65 100644
--- a/source/app/src/wandac.cpp
+++ b/source/app/src/wandac.cpp
@@ -4,7 +4,8 @@
#include <wanda/system/logging.hpp>
#include <wanda/system/xdg.hpp>
-#include <asio.hpp>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/post.hpp>
#include <lyra/lyra.hpp>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/spdlog.h>
@@ -39,7 +40,7 @@ struct cli
struct listener : wanda::control::commander::listener
{
- listener(::cli & cli, asio::io_service & service)
+ listener(::cli & cli, boost::asio::io_context & service)
: m_cli{cli}
, m_service{service}
{
@@ -50,13 +51,14 @@ struct listener : wanda::control::commander::listener
if (m_cli.command == "change")
{
commander.send(wanda::proto::make_change_command());
- m_service.post([&] { commander.stop(); });
+
+ post(m_service, [&] { commander.stop(); });
}
}
private:
::cli & m_cli;
- asio::io_service & m_service;
+ boost::asio::io_context & m_service;
};
int main(int argc, char const * const * argv)
@@ -77,7 +79,7 @@ int main(int argc, char const * const * argv)
auto interface =
wanda::system::xdg_path_for(wanda::system::xdg_directory::runtime_dir, wanda::system::environment{}) /
".wanda_interface";
- auto service = asio::io_service{};
+ auto service = boost::asio::io_context{};
auto listener = ::listener{cli, service};
auto commander = wanda::control::commander{service, interface, listener};
diff --git a/source/app/src/wandad.cpp b/source/app/src/wandad.cpp
index a610b8a..e7ee772 100644
--- a/source/app/src/wandad.cpp
+++ b/source/app/src/wandad.cpp
@@ -8,7 +8,8 @@
#include <wanda/system/wallpaper.hpp>
#include <wanda/system/xdg.hpp>
-#include <asio.hpp>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/signal_set.hpp>
#include <lyra/lyra.hpp>
#include <spdlog/sinks/stdout_color_sinks.h>
@@ -106,7 +107,7 @@ int main(int argc, char const * const * argv)
with(wanda::system::scan({cli.wallpaper_directory}, image_filter),
[&](auto const & list) {
- auto service = asio::io_service{};
+ auto service = boost::asio::io_context{};
auto socket_path =
wanda::system::xdg_path_for(wanda::system::xdg_directory::runtime_dir, wanda::system::environment{}) /
".wanda_interface";
@@ -126,7 +127,7 @@ int main(int argc, char const * const * argv)
return;
}
- auto signals = asio::signal_set{service, SIGINT, SIGTERM};
+ auto signals = boost::asio::signal_set{service, SIGINT, SIGTERM};
signals.async_wait([&](auto const & error, auto const signal) {
if (!error)
{
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))
{