Skip to content

Commit

Permalink
feat: Remove support for deprecated asio::execution functions and rem…
Browse files Browse the repository at this point in the history
…ove several unused symbols and files
  • Loading branch information
Tradias committed Feb 9, 2024
1 parent 7d8e33e commit dc2610e
Show file tree
Hide file tree
Showing 29 changed files with 91 additions and 865 deletions.
1 change: 0 additions & 1 deletion src/agrpc/alarm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <agrpc/detail/grpc_sender.hpp>
#include <agrpc/detail/initiate_sender_implementation.hpp>
#include <agrpc/detail/query_grpc_context.hpp>
#include <agrpc/detail/wait.hpp>
#include <agrpc/grpc_executor.hpp>

AGRPC_NAMESPACE_BEGIN()
Expand Down
3 changes: 2 additions & 1 deletion src/agrpc/client_rpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ namespace detail
* @since 2.6.0
*/
template <class StubT, class RequestT, class ResponseT, template <class> class ResponderT,
detail::ClientUnaryRequest<StubT, RequestT, ResponderT<ResponseT>> PrepareAsyncUnary, class Executor>
detail::PrepareAsyncClientUnaryRequest<StubT, RequestT, ResponderT<ResponseT>> PrepareAsyncUnary,
class Executor>
class ClientRPCUnaryBase<PrepareAsyncUnary, Executor> : public detail::ClientRPCBase<ResponderT<ResponseT>, Executor>
{
private:
Expand Down
50 changes: 49 additions & 1 deletion src/agrpc/detail/alarm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,60 @@
#include <agrpc/detail/forward.hpp>
#include <agrpc/detail/grpc_sender.hpp>
#include <agrpc/detail/sender_implementation.hpp>
#include <agrpc/detail/wait.hpp>

AGRPC_NAMESPACE_BEGIN()

namespace detail
{
template <class Deadline>
struct AlarmInitFunction
{
grpc::Alarm& alarm_;
Deadline deadline_;

void operator()(agrpc::GrpcContext& grpc_context, void* tag) const
{
alarm_.Set(grpc_context.get_completion_queue(), deadline_, tag);
}
};

template <class Deadline>
AlarmInitFunction(grpc::Alarm&, const Deadline&) -> AlarmInitFunction<Deadline>;

struct AlarmCancellationFunction
{
grpc::Alarm& alarm_;

#if !defined(AGRPC_UNIFEX) && !defined(AGRPC_STDEXEC)
explicit
#endif
AlarmCancellationFunction(grpc::Alarm& alarm) noexcept
: alarm_(alarm)
{
}

template <class Deadline>
#if !defined(AGRPC_UNIFEX) && !defined(AGRPC_STDEXEC)
explicit
#endif
AlarmCancellationFunction(const detail::AlarmInitFunction<Deadline>& init_function) noexcept
: alarm_(init_function.alarm_)
{
}

void operator()() const { alarm_.Cancel(); }

#ifdef AGRPC_ASIO_HAS_CANCELLATION_SLOT
void operator()(asio::cancellation_type type) const
{
if (static_cast<bool>(type & asio::cancellation_type::all))
{
operator()();
}
}
#endif
};

template <class Executor>
struct MoveAlarmSenderImplementation
{
Expand Down
4 changes: 0 additions & 4 deletions src/agrpc/detail/asio_forward.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
//
#include <asio/version.hpp>
//
#include <asio/any_io_executor.hpp>
#include <asio/associated_allocator.hpp>
#include <asio/associated_executor.hpp>
#include <asio/async_result.hpp>
#include <asio/bind_executor.hpp>
#include <asio/error.hpp>
#include <asio/execution/allocator.hpp>
#include <asio/execution/blocking.hpp>
Expand Down Expand Up @@ -63,11 +61,9 @@
//
#include <boost/version.hpp>
//
#include <boost/asio/any_io_executor.hpp>
#include <boost/asio/associated_allocator.hpp>
#include <boost/asio/associated_executor.hpp>
#include <boost/asio/async_result.hpp>
#include <boost/asio/bind_executor.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/execution/allocator.hpp>
#include <boost/asio/execution/blocking.hpp>
Expand Down
34 changes: 9 additions & 25 deletions src/agrpc/detail/asio_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,12 @@ inline constexpr bool IS_EXECUTOR_PROVIDER = false;
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 do_execute(Executor&& executor, Function&& function)
{
asio::execution::execute(static_cast<Executor&&>(executor), static_cast<Function&&>(function));
}
#else
template <class Executor, class Function>
void do_execute(Executor&& executor, Function&& function)
{
static_cast<Executor&&>(executor).execute(static_cast<Function&&>(function));
}
#endif

template <class Executor, class Function, class Allocator>
void post_with_allocator(Executor&& executor, Function&& function, const Allocator& allocator)
{
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));
asio::prefer(asio::require(static_cast<Executor&&>(executor), asio::execution::blocking_t::never),
asio::execution::relationship_t::fork, asio::execution::allocator(allocator))
.execute(static_cast<Function&&>(function));
}

template <class CompletionHandler, class Function, class IOExecutor>
Expand All @@ -76,12 +60,12 @@ void complete_immediately(CompletionHandler&& completion_handler, Function&& fun
return (io_executor);
}
}());
detail::do_execute(
asio::prefer(std::move(executor), asio::execution::allocator(allocator)),
[ch = static_cast<CompletionHandler&&>(completion_handler), f = static_cast<Function&&>(function)]() mutable
{
static_cast<Function&&>(f)(static_cast<CompletionHandler&&>(ch));
});
asio::prefer(std::move(executor), asio::execution::allocator(allocator))
.execute(
[ch = static_cast<CompletionHandler&&>(completion_handler), f = static_cast<Function&&>(function)]() mutable
{
static_cast<Function&&>(f)(static_cast<CompletionHandler&&>(ch));
});
#else
auto executor = asio::get_associated_executor(completion_handler, io_executor);
detail::post_with_allocator(
Expand Down
98 changes: 0 additions & 98 deletions src/agrpc/detail/associated_completion_handler.hpp

This file was deleted.

41 changes: 0 additions & 41 deletions src/agrpc/detail/atomic.hpp

This file was deleted.

26 changes: 0 additions & 26 deletions src/agrpc/detail/basic_sender.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,30 +274,4 @@ class BasicSenderOperationState

AGRPC_NAMESPACE_END

#ifdef AGRPC_ASIO_HAS_SENDER_RECEIVER
#if !defined(BOOST_ASIO_HAS_DEDUCED_CONNECT_MEMBER_TRAIT) && !defined(ASIO_HAS_DEDUCED_CONNECT_MEMBER_TRAIT)
template <class Initiation, class Implementation, class R>
struct agrpc::asio::traits::connect_member<agrpc::detail::BasicSender<Initiation, Implementation>, R>
{
static constexpr bool is_valid = true;
static constexpr bool is_noexcept =
noexcept(std::declval<agrpc::detail::BasicSender<Initiation, Implementation>>().connect(std::declval<R>()));

using result_type =
decltype(std::declval<agrpc::detail::BasicSender<Initiation, Implementation>>().connect(std::declval<R>()));
};
#endif

#if !defined(BOOST_ASIO_HAS_DEDUCED_START_MEMBER_TRAIT) && !defined(ASIO_HAS_DEDUCED_START_MEMBER_TRAIT)
template <class Initiation, class Implementation, class Receiver>
struct agrpc::asio::traits::start_member<agrpc::detail::BasicSenderOperationState<Initiation, Implementation, Receiver>>
{
static constexpr bool is_valid = true;
static constexpr bool is_noexcept = true;

using result_type = void;
};
#endif
#endif

#endif // AGRPC_DETAIL_BASIC_SENDER_HPP
Loading

0 comments on commit dc2610e

Please sign in to comment.