asio-grpc v1.5.0
Asynchronous gRPC with Asio/unified executors
agrpc::detail::UseSenderFn Struct Reference

Function object to create sender completion tokens. More...

#include <agrpc/useSender.hpp>

Public Member Functions

template<class Allocator , std::uint32_t Options>
constexpr auto operator() (const agrpc::BasicGrpcExecutor< Allocator, Options > &executor) const noexcept
 Overload for BasicGrpcExecutor.
 
constexpr auto operator() (agrpc::GrpcContext &context) const noexcept
 Overload for GrpcContext.
 

Detailed Description

Function object to create sender completion tokens.

The completion token created by this function causes other asynchronous functions in this library to return a Sender. This is particularly useful for libunifex where senders are also awaitable:

unifex::task<void> unified_executors(example::v1::Example::Stub& stub, agrpc::GrpcContext& grpc_context)
{
grpc::ClientContext client_context;
example::v1::Request request;
std::unique_ptr<grpc::ClientAsyncReader<example::v1::Response>> reader;
co_await agrpc::request(&example::v1::Example::Stub::AsyncServerStreaming, stub, client_context, request, reader,
agrpc::use_sender(grpc_context));
example::v1::Response response;
co_await agrpc::read(*reader, response, agrpc::use_sender(grpc_context));
grpc::Status status;
co_await agrpc::finish(*reader, status, agrpc::use_sender(grpc_context));
}
Execution context based on grpc::CompletionQueue
Definition: grpcContext.hpp:50
constexpr detail::UseSenderFn use_sender
Create sender completion token.
Definition: useSender.hpp:66
constexpr detail::RequestFn request
Start a new RPC.
Definition: rpc.hpp:1394
constexpr detail::ReadFn read
Read from a streaming RPC.
Definition: rpc.hpp:1403
constexpr detail::FinishFn finish
Finish a RPC.
Definition: rpc.hpp:1430