From 56e7f16656c02180add92fda1e285fedd1e8651f Mon Sep 17 00:00:00 2001 From: Dennis Hezel Date: Sun, 24 Dec 2023 11:36:37 +0100 Subject: [PATCH] fix: Detection of asio::execution and standalone asio + asio::soawn usage for asio 1.24+ --- src/agrpc/detail/asio_forward.hpp | 4 ++++ src/agrpc/detail/execution_asio.hpp | 7 ++++--- test/src/test_grpc_context_20.cpp | 2 ++ test/utils/utils/asio_forward.hpp | 5 ++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/agrpc/detail/asio_forward.hpp b/src/agrpc/detail/asio_forward.hpp index 7b25d3fc..753870d2 100644 --- a/src/agrpc/detail/asio_forward.hpp +++ b/src/agrpc/detail/asio_forward.hpp @@ -57,6 +57,10 @@ #define AGRPC_ASIO_HAS_BIND_ALLOCATOR #endif +#if (ASIO_VERSION >= 102400) +#define AGRPC_ASIO_HAS_NEW_SPAWN +#endif + #if (ASIO_VERSION >= 102700) #include diff --git a/src/agrpc/detail/execution_asio.hpp b/src/agrpc/detail/execution_asio.hpp index 43467afc..83ff62b7 100644 --- a/src/agrpc/detail/execution_asio.hpp +++ b/src/agrpc/detail/execution_asio.hpp @@ -18,7 +18,7 @@ #include #include -#if defined(AGRPC_STANDALONE_ASIO) && ((ASIO_VERSION < 102500) || !defined(ASIO_NO_DEPRECATED)) +#if defined(AGRPC_STANDALONE_ASIO) && (ASIO_VERSION < 102500 || (ASIO_VERSION < 102900 && !defined(ASIO_NO_DEPRECATED))) #include #include #include @@ -26,7 +26,8 @@ #include #define AGRPC_ASIO_HAS_SENDER_RECEIVER -#elif defined(AGRPC_BOOST_ASIO) && ((BOOST_VERSION < 108100) || !defined(BOOST_ASIO_NO_DEPRECATED)) +#elif defined(AGRPC_BOOST_ASIO) && \ + (BOOST_VERSION < 108100 || (BOOST_VERSION < 108400 && !defined(BOOST_ASIO_NO_DEPRECATED))) #include #include #include @@ -58,7 +59,7 @@ decltype(auto) get_allocator(const Object& object) struct GetSchedulerFn { template - decltype(auto) operator()(const Object & object) const + decltype(auto) operator()(const Object& object) const { return asio::get_associated_executor(object); } diff --git a/test/src/test_grpc_context_20.cpp b/test/src/test_grpc_context_20.cpp index fa603fdc..615c78a6 100644 --- a/test/src/test_grpc_context_20.cpp +++ b/test/src/test_grpc_context_20.cpp @@ -30,7 +30,9 @@ TEST_CASE("GrpcExecutor fulfills Executor TS concepts") { CHECK(asio::execution::executor); +#ifdef AGRPC_ASIO_HAS_SENDER_RECEIVER CHECK(asio::execution::executor_of); +#endif } #ifdef AGRPC_ASIO_HAS_SENDER_RECEIVER diff --git a/test/utils/utils/asio_forward.hpp b/test/utils/utils/asio_forward.hpp index 5bc83185..536fc6dd 100644 --- a/test/utils/utils/asio_forward.hpp +++ b/test/utils/utils/asio_forward.hpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -43,6 +42,10 @@ #include #endif +#ifdef AGRPC_ASIO_HAS_SENDER_RECEIVER +#include +#endif + #ifdef ASIO_HAS_CONCEPTS #define AGRPC_TEST_ASIO_HAS_CONCEPTS #endif