From 26a8e227b4b5f80c29f9378d586456e16c0ed46a Mon Sep 17 00:00:00 2001 From: qicosmos Date: Tue, 2 Sep 2025 16:52:20 +0800 Subject: [PATCH] fix compile --- examples/client/main.cpp | 4 ++-- include/rest_rpc/io_context_pool.hpp | 5 +++-- include/rest_rpc/rpc_client.hpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/client/main.cpp b/examples/client/main.cpp index 381e8cc..e27e9e7 100644 --- a/examples/client/main.cpp +++ b/examples/client/main.cpp @@ -218,13 +218,13 @@ void test_echo() { { // safe call, same with `client.call("echo", "test")` - auto result = client.call("test"); + auto result = client.call_s("test"); std::cout << result << std::endl; } { // safe call member function - auto result = client.call<&dummy::add>(1, 2); + auto result = client.call_s<&dummy::add>(1, 2); std::cout << result << std::endl; } diff --git a/include/rest_rpc/io_context_pool.hpp b/include/rest_rpc/io_context_pool.hpp index 31d988e..2e8ca9a 100644 --- a/include/rest_rpc/io_context_pool.hpp +++ b/include/rest_rpc/io_context_pool.hpp @@ -12,7 +12,7 @@ public: for (size_t i = 0; i < pool_size; i++) { auto io_ctx = std::make_shared(); - works_.push_back(asio::io_context::work(*io_ctx)); + works_.push_back(asio::make_work_guard(*io_ctx)); io_contexts_.emplace_back(io_ctx); } } @@ -47,7 +47,8 @@ public: private: std::vector> io_contexts_; - std::vector works_; + std::vector> + works_; std::once_flag run_flag_; std::once_flag stop_flag_; std::atomic next_ = 0; diff --git a/include/rest_rpc/rpc_client.hpp b/include/rest_rpc/rpc_client.hpp index 0990944..03e6c83 100644 --- a/include/rest_rpc/rpc_client.hpp +++ b/include/rest_rpc/rpc_client.hpp @@ -254,7 +254,7 @@ public: return call(rpc_name, std::forward(args)...); } - template auto call(Args &&...args) { + template auto call_s(Args &&...args) { using args_tuple = typename function_traits::tuple_type; static_assert(std::is_constructible_v, Args...>, "called rpc function and arguments are not match");