19 #ifndef GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_H
20 #define GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_H
35 class ClientAsyncResponseReader;
90 template <
class R,
class W,
class BaseR = R,
class BaseW = W>
100 SetupRequest<BaseR, BaseW>(
101 call.
call(), &result->single_buf_, &result->read_initial_metadata_,
102 &result->finish_,
static_cast<const BaseW&
>(request));
109 template <
class R,
class W>
115 read_initial_metadata,
121 using SingleBufType =
128 SingleBufType* single_buf =
130 call,
sizeof(SingleBufType))) SingleBufType;
131 *single_buf_ptr = single_buf;
134 single_buf->ClientSendClose();
141 *read_initial_metadata =
144 auto* single_buf =
static_cast<SingleBufType*
>(single_buf_view);
145 single_buf->set_output_tag(tag);
146 single_buf->RecvInitialMetadata(context);
147 call->PerformOps(single_buf);
158 bool initial_metadata_read,
161 Status* status,
void* tag) {
162 if (initial_metadata_read) {
166 FinishBufType* finish_buf =
168 call->call(),
sizeof(FinishBufType))) FinishBufType;
169 *finish_buf_ptr = finish_buf;
170 finish_buf->set_output_tag(tag);
171 finish_buf->RecvMessage(
static_cast<R*
>(msg));
172 finish_buf->AllowNoMessage();
174 call->PerformOps(finish_buf);
176 auto* single_buf =
static_cast<SingleBufType*
>(single_buf_view);
177 single_buf->set_output_tag(tag);
178 single_buf->RecvInitialMetadata(context);
179 single_buf->RecvMessage(
static_cast<R*
>(msg));
180 single_buf->AllowNoMessage();
181 single_buf->ClientRecvStatus(context, status);
182 call->PerformOps(single_buf);
191 context->initial_metadata_flags());
204 const W& request,
bool start) {
205 auto* result = ClientAsyncResponseReaderHelper::Create<R>(
206 channel, cq, method, context, request);
223 static void operator delete(
void* , std::size_t size) {
249 read_initial_metadata_(context_, &call_, single_buf_, tag);
250 initial_metadata_read_ =
true;
260 finish_(context_, &call_, initial_metadata_read_, single_buf_, &finish_buf_,
261 static_cast<void*
>(msg), status, tag);
268 bool started_ =
false;
269 bool initial_metadata_read_ =
false;
273 : context_(context), call_(call) {}
276 static void*
operator new(std::size_t size);
277 static void*
operator new(std::size_t ,
void* p) {
return p; }
279 internal::CallOpSendInitialMetadata* single_buf_;
280 internal::CallOpSetInterface* finish_buf_ =
nullptr;
281 std::function<void(ClientContext*, internal::Call*,
282 internal::CallOpSendInitialMetadata*,
void*)>
283 read_initial_metadata_;
284 std::function<void(ClientContext*, internal::Call*,
285 bool initial_metadata_read,
286 internal::CallOpSendInitialMetadata*,
287 internal::CallOpSetInterface**,
void*,
Status*,
void*)>
298 : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
310 meta_buf_.set_output_tag(tag);
311 meta_buf_.SendInitialMetadata(&ctx_->initial_metadata_,
312 ctx_->initial_metadata_flags());
316 ctx_->sent_initial_metadata_ =
true;
336 finish_buf_.set_output_tag(tag);
337 finish_buf_.set_core_cq_tag(&finish_buf_);
338 if (!ctx_->sent_initial_metadata_) {
339 finish_buf_.SendInitialMetadata(&ctx_->initial_metadata_,
340 ctx_->initial_metadata_flags());
344 ctx_->sent_initial_metadata_ =
true;
348 finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_,
349 finish_buf_.SendMessage(msg));
351 finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, status);
370 finish_buf_.set_output_tag(tag);
371 if (!ctx_->sent_initial_metadata_) {
372 finish_buf_.SendInitialMetadata(&ctx_->initial_metadata_,
373 ctx_->initial_metadata_flags());
377 ctx_->sent_initial_metadata_ =
true;
379 finish_buf_.ServerSendStatus(&ctx_->trailing_metadata_, status);
Codegen interface for grpc::Channel.
Definition: channel_interface.h:71
Async API for client-side unary RPCs, where the message response received from the server is of type ...
Definition: async_unary_call.h:220
void StartCall() override
Start the call that was set up by the constructor, but only if the constructor was invoked through th...
Definition: async_unary_call.h:234
void ReadInitialMetadata(void *tag) override
See ClientAsyncResponseReaderInterface::ReadInitialMetadata for semantics.
Definition: async_unary_call.h:246
void Finish(R *msg, ::grpc::Status *status, void *tag) override
See ClientAsyncResponseReaderInterface::Finish for semantics.
Definition: async_unary_call.h:258
An interface relevant for async client side unary RPCs (which send one request message to a server an...
Definition: async_unary_call.h:40
virtual void StartCall()=0
Start the call that was set up by the constructor, but only if the constructor was invoked through th...
virtual void ReadInitialMetadata(void *tag)=0
Request notification of the reading of initial metadata.
virtual ~ClientAsyncResponseReaderInterface()
Definition: async_unary_call.h:42
virtual void Finish(R *msg, ::grpc::Status *status, void *tag)=0
Request to receive the server's response msg and final status for the call, and to notify tag on this...
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:193
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:102
virtual void * grpc_call_arena_alloc(grpc_call *call, size_t length)=0
Async server-side API for handling unary calls, where the single response message sent to the client ...
Definition: async_unary_call.h:295
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_unary_call.h:307
ServerAsyncResponseWriter(::grpc::ServerContext *ctx)
Definition: async_unary_call.h:297
void Finish(const W &msg, const ::grpc::Status &status, void *tag)
Indicate that the stream is to be finished and request notification when the server has sent the appr...
Definition: async_unary_call.h:335
void FinishWithError(const ::grpc::Status &status, void *tag)
Indicate that the stream is to be finished with a non-OK status, and request notification for when th...
Definition: async_unary_call.h:368
A ServerContext or CallbackServerContext allows the code implementing a service handler to:
Definition: server_context.h:538
bool compression_level_set() const
Return a bool indicating whether the compression level for this call has been set (either implicitly ...
Definition: server_context.h:243
grpc_compression_level compression_level() const
Return the compression algorithm to be used by the server call.
Definition: server_context.h:228
Did it work? If it didn't, why?
Definition: status.h:31
Straightforward wrapping of the C call object.
Definition: call.h:35
grpc_call * call() const
Definition: call.h:69
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:65
Definition: call_op_set.h:769
void ClientRecvStatus(::grpc::ClientContext *context, Status *status)
Definition: call_op_set.h:774
Definition: call_op_set.h:619
Definition: call_op_set.h:424
Definition: call_op_set.h:282
Definition: call_op_set.h:654
Primary implementation of CallOpSetInterface.
Definition: call_op_set.h:867
An abstract collection of call ops, used to generate the grpc_call_op structure to pass down to the l...
Definition: call_op_set_interface.h:34
Definition: async_unary_call.h:198
static ClientAsyncResponseReader< R > * Create(::grpc::ChannelInterface *channel, ::grpc::CompletionQueue *cq, const ::grpc::internal::RpcMethod &method, ::grpc::ClientContext *context, const W &request, bool start)
Definition: async_unary_call.h:201
Definition: async_unary_call.h:76
static void StartCall(::grpc::ClientContext *context, ::grpc::internal::CallOpSendInitialMetadata *single_buf)
Definition: async_unary_call.h:187
static void SetupRequest(grpc_call *call, ::grpc::internal::CallOpSendInitialMetadata **single_buf_ptr, std::function< void(ClientContext *, internal::Call *, internal::CallOpSendInitialMetadata *, void *)> *read_initial_metadata, std::function< void(ClientContext *, internal::Call *, bool initial_metadata_read, internal::CallOpSendInitialMetadata *, internal::CallOpSetInterface **, void *, Status *, void *)> *finish, const W &request)
Definition: async_unary_call.h:110
static ClientAsyncResponseReader< R > * Create(::grpc::ChannelInterface *channel, ::grpc::CompletionQueue *cq, const ::grpc::internal::RpcMethod &method, ::grpc::ClientContext *context, const W &request)
Start a call and write the request out if start is set.
Definition: async_unary_call.h:91
Definition: service_type.h:37
void operator()(void *)
Definition: async_unary_call.h:402
void operator()(void *)
Definition: async_unary_call.h:407
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:146
#define GPR_CODEGEN_DEBUG_ASSERT(x)
Codegen specific version of GPR_DEBUG_ASSERT.
Definition: core_codegen_interface.h:155
::google::protobuf::util::Status Status
Definition: config_protobuf.h:91
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
CoreCodegenInterface * g_core_codegen_interface
Null-initializes the global gRPC variables for the codegen library.
Definition: completion_queue.h:96
Definition: async_unary_call.h:398