asio-grpc v3.1.0
Asynchronous gRPC with Asio/unified executors
agrpc::UseSender Struct Reference

Sender completion token. More...

#include <agrpc/use_sender.hpp>

Public Types

template<class T >
using as_default_on_t = typename T::template rebind_executor< detail::ExecutorWithDefault< UseSender, typename T::executor_type > >::other
 Type alias to adapt an I/O object to use agrpc::UseSender as its default completion token type. More...
 

Detailed Description

Sender completion token.

This completion token causes functions in this library to return a sender. Particularly useful for libunifex where senders are also awaitable:

unifex::task<void> server_streaming_example(agrpc::GrpcContext& grpc_context, example::v1::Example::Stub& stub)
{
grpc::ClientContext client_context;
RPC::Request request;
RPC rpc{grpc_context};
co_await rpc.start(stub, request, agrpc::use_sender);
RPC::Response response;
co_await rpc.read(response, agrpc::use_sender);
co_await rpc.finish(agrpc::use_sender);
}
Primary ClientRPC template.
Definition: forward.hpp:57
Execution context based on grpc::CompletionQueue
Definition: grpc_context.hpp:50
constexpr agrpc::UseSender use_sender
Instance and factory for sender completion tokens.
Definition: use_sender.hpp:55

Note when using libunifex or stdexec exclusively then agrpc::use_sender is already the default completion token.

Member Typedef Documentation

◆ as_default_on_t

template<class T >
using agrpc::UseSender::as_default_on_t = typename T::template rebind_executor<detail::ExecutorWithDefault<UseSender, typename T::executor_type> >::other

Type alias to adapt an I/O object to use agrpc::UseSender as its default completion token type.

Only applicable to I/O objects of this library.