Skip to content

Commit

Permalink
fix: Detection of asio::execution and standalone asio + asio::soawn u…
Browse files Browse the repository at this point in the history
…sage for asio 1.24+
  • Loading branch information
Tradias committed Dec 24, 2023
1 parent b393038 commit 56e7f16
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/agrpc/detail/asio_forward.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <asio/associated_immediate_executor.hpp>

Expand Down
7 changes: 4 additions & 3 deletions src/agrpc/detail/execution_asio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
#include <agrpc/detail/asio_forward.hpp>
#include <agrpc/detail/config.hpp>

#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 <asio/execution/connect.hpp>
#include <asio/execution/set_done.hpp>
#include <asio/execution/set_error.hpp>
#include <asio/execution/set_value.hpp>
#include <asio/execution/start.hpp>

#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 <boost/asio/execution/connect.hpp>
#include <boost/asio/execution/set_done.hpp>
#include <boost/asio/execution/set_error.hpp>
Expand Down Expand Up @@ -58,7 +59,7 @@ decltype(auto) get_allocator(const Object& object)
struct GetSchedulerFn
{
template <class Object>
decltype(auto) operator()(const Object & object) const
decltype(auto) operator()(const Object& object) const
{
return asio::get_associated_executor(object);
}
Expand Down
2 changes: 2 additions & 0 deletions test/src/test_grpc_context_20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
TEST_CASE("GrpcExecutor fulfills Executor TS concepts")
{
CHECK(asio::execution::executor<agrpc::GrpcExecutor>);
#ifdef AGRPC_ASIO_HAS_SENDER_RECEIVER
CHECK(asio::execution::executor_of<agrpc::GrpcExecutor, test::InvocableArchetype>);
#endif
}

#ifdef AGRPC_ASIO_HAS_SENDER_RECEIVER
Expand Down
5 changes: 4 additions & 1 deletion test/utils/utils/asio_forward.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <asio/coroutine.hpp>
#include <asio/error.hpp>
#include <asio/execution.hpp>
#include <asio/execution/submit.hpp>
#include <asio/io_context.hpp>
#include <asio/post.hpp>
#include <asio/spawn.hpp>
Expand All @@ -43,6 +42,10 @@
#include <asio/experimental/parallel_group.hpp>
#endif

#ifdef AGRPC_ASIO_HAS_SENDER_RECEIVER
#include <asio/execution/submit.hpp>
#endif

#ifdef ASIO_HAS_CONCEPTS
#define AGRPC_TEST_ASIO_HAS_CONCEPTS
#endif
Expand Down

0 comments on commit 56e7f16

Please sign in to comment.