Skip to content

Commit

Permalink
fix: Work around name conflict in detail::execution
Browse files Browse the repository at this point in the history
  • Loading branch information
Tradias committed Dec 19, 2023
1 parent 2fecf56 commit b393038
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
14 changes: 8 additions & 6 deletions src/agrpc/detail/asio_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ template <class T>
inline constexpr bool IS_EXECUTOR_PROVIDER<T, decltype((void)std::declval<T>().get_executor())> = true;

#ifdef AGRPC_ASIO_HAS_SENDER_RECEIVER
// Must not be named `execute`
template <class Executor, class Function>
void execute(Executor&& executor, Function&& function)
void do_execute(Executor&& executor, Function&& function)
{
asio::execution::execute(static_cast<Executor&&>(executor), static_cast<Function&&>(function));
}
#else
template <class Executor, class Function>
void execute(Executor&& executor, Function&& function)
void do_execute(Executor&& executor, Function&& function)
{
static_cast<Executor&&>(executor).execute(static_cast<Function&&>(function));
}
Expand All @@ -48,9 +49,10 @@ void execute(Executor&& executor, Function&& function)
template <class Executor, class Function, class Allocator>
void post_with_allocator(Executor&& executor, Function&& function, const Allocator& allocator)
{
detail::execute(asio::prefer(asio::require(static_cast<Executor&&>(executor), asio::execution::blocking_t::never),
asio::execution::relationship_t::fork, asio::execution::allocator(allocator)),
static_cast<Function&&>(function));
detail::do_execute(
asio::prefer(asio::require(static_cast<Executor&&>(executor), asio::execution::blocking_t::never),
asio::execution::relationship_t::fork, asio::execution::allocator(allocator)),
static_cast<Function&&>(function));
}

template <class CompletionHandler, class Function, class IOExecutor>
Expand All @@ -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<CompletionHandler&&>(completion_handler), f = static_cast<Function&&>(function)]() mutable
{
Expand Down
2 changes: 1 addition & 1 deletion src/agrpc/detail/work_tracking_completion_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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&&>(handler), arg_tuple = detail::Tuple{static_cast<Args&&>(args)...}]() mutable
{
Expand Down
6 changes: 3 additions & 3 deletions test/src/test_grpc_context_17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit b393038

Please sign in to comment.