From b393038a58da8d59ef7a36db1fe9e528bad61d06 Mon Sep 17 00:00:00 2001 From: Dennis Hezel Date: Tue, 19 Dec 2023 17:03:23 +0100 Subject: [PATCH] fix: Work around name conflict in detail::execution --- src/agrpc/detail/asio_utils.hpp | 14 ++++++++------ .../detail/work_tracking_completion_handler.hpp | 2 +- test/src/test_grpc_context_17.cpp | 6 +++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/agrpc/detail/asio_utils.hpp b/src/agrpc/detail/asio_utils.hpp index 22d44bb0..55e387af 100644 --- a/src/agrpc/detail/asio_utils.hpp +++ b/src/agrpc/detail/asio_utils.hpp @@ -32,14 +32,15 @@ template inline constexpr bool IS_EXECUTOR_PROVIDER().get_executor())> = true; #ifdef AGRPC_ASIO_HAS_SENDER_RECEIVER +// Must not be named `execute` template -void execute(Executor&& executor, Function&& function) +void do_execute(Executor&& executor, Function&& function) { asio::execution::execute(static_cast(executor), static_cast(function)); } #else template -void execute(Executor&& executor, Function&& function) +void do_execute(Executor&& executor, Function&& function) { static_cast(executor).execute(static_cast(function)); } @@ -48,9 +49,10 @@ void execute(Executor&& executor, Function&& function) template void post_with_allocator(Executor&& executor, Function&& function, const Allocator& allocator) { - detail::execute(asio::prefer(asio::require(static_cast(executor), asio::execution::blocking_t::never), - asio::execution::relationship_t::fork, asio::execution::allocator(allocator)), - static_cast(function)); + detail::do_execute( + asio::prefer(asio::require(static_cast(executor), asio::execution::blocking_t::never), + asio::execution::relationship_t::fork, asio::execution::allocator(allocator)), + static_cast(function)); } template @@ -74,7 +76,7 @@ void complete_immediately(CompletionHandler&& completion_handler, Function&& fun return (io_executor); } }()); - detail::execute( + detail::do_execute( asio::prefer(std::move(executor), asio::execution::allocator(allocator)), [ch = static_cast(completion_handler), f = static_cast(function)]() mutable { diff --git a/src/agrpc/detail/work_tracking_completion_handler.hpp b/src/agrpc/detail/work_tracking_completion_handler.hpp index cc46f961..acc29b09 100644 --- a/src/agrpc/detail/work_tracking_completion_handler.hpp +++ b/src/agrpc/detail/work_tracking_completion_handler.hpp @@ -67,7 +67,7 @@ void dispatch_with_args(Handler&& handler, Args&&... args) { auto executor = asio::prefer(asio::get_associated_executor(handler), asio::execution::blocking_t::possibly, asio::execution::allocator(asio::get_associated_allocator(handler))); - detail::execute( + detail::do_execute( std::move(executor), [h = static_cast(handler), arg_tuple = detail::Tuple{static_cast(args)...}]() mutable { diff --git a/test/src/test_grpc_context_17.cpp b/test/src/test_grpc_context_17.cpp index 1af45915..3b542960 100644 --- a/test/src/test_grpc_context_17.cpp +++ b/test/src/test_grpc_context_17.cpp @@ -496,14 +496,14 @@ TEST_CASE_FIXTURE(test::GrpcContextTest, "post/execute with allocator") } SUBCASE("asio::execute before grpc_context.run()") { - agrpc::detail::execute(get_tracking_allocator_executor(), test::NoOp{}); + agrpc::detail::do_execute(get_tracking_allocator_executor(), test::NoOp{}); } SUBCASE("asio::execute after grpc_context.run() from same thread") { asio::post(grpc_context, [&, exec = get_tracking_allocator_executor()] { - agrpc::detail::execute(exec, test::NoOp{}); + agrpc::detail::do_execute(exec, test::NoOp{}); }); } grpc_context.run(); @@ -541,7 +541,7 @@ TEST_CASE_FIXTURE(test::GrpcContextTest, "dispatch with allocator") TEST_CASE_FIXTURE(test::GrpcContextTest, "execute with throwing allocator") { const auto executor = asio::require(get_executor(), asio::execution::allocator(test::ThrowingAllocator<>{})); - CHECK_THROWS(agrpc::detail::execute(executor, test::NoOp{})); + CHECK_THROWS(agrpc::detail::do_execute(executor, test::NoOp{})); } TEST_CASE_FIXTURE(test::GrpcContextTest, "asio::post with throwing completion handler")