19 #ifndef GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_H 20 #define GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_H 32 class CompletionQueue;
69 virtual void Finish(R* msg,
Status* status,
void* tag) = 0;
85 const ::grpc::internal::RpcMethod& method,
ClientContext* context,
86 const W& request,
bool start) {
88 return new (g_core_codegen_interface->grpc_call_arena_alloc(
102 static void operator delete(
void* ptr, std::size_t size) {
111 static void operator delete(
void*,
void*) { assert(0); }
129 single_buf.set_output_tag(tag);
130 single_buf.RecvInitialMetadata(context_);
131 call_.PerformOps(&single_buf);
132 initial_metadata_read_ =
true;
142 if (initial_metadata_read_) {
143 finish_buf.set_output_tag(tag);
144 finish_buf.RecvMessage(msg);
145 finish_buf.AllowNoMessage();
146 finish_buf.ClientRecvStatus(context_, status);
147 call_.PerformOps(&finish_buf);
149 single_buf.set_output_tag(tag);
150 single_buf.RecvInitialMetadata(context_);
151 single_buf.RecvMessage(msg);
152 single_buf.AllowNoMessage();
153 single_buf.ClientRecvStatus(context_, status);
154 call_.PerformOps(&single_buf);
163 bool initial_metadata_read_ =
false;
167 const W& request,
bool start)
168 : context_(context), call_(call), started_(start) {
172 single_buf.ClientSendClose();
173 if (start) StartCallInternal();
176 void StartCallInternal() {
177 single_buf.SendInitialMetadata(context_->send_initial_metadata_,
178 context_->initial_metadata_flags());
182 static void*
operator new(std::size_t size);
183 static void*
operator new(std::size_t size,
void* p) {
return p; }
204 : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
216 meta_buf_.set_output_tag(tag);
217 meta_buf_.SendInitialMetadata(ctx_->initial_metadata_,
218 ctx_->initial_metadata_flags());
219 if (ctx_->compression_level_set()) {
220 meta_buf_.set_compression_level(ctx_->compression_level());
222 ctx_->sent_initial_metadata_ =
true;
242 finish_buf_.set_output_tag(tag);
243 if (!ctx_->sent_initial_metadata_) {
244 finish_buf_.SendInitialMetadata(ctx_->initial_metadata_,
245 ctx_->initial_metadata_flags());
246 if (ctx_->compression_level_set()) {
247 finish_buf_.set_compression_level(ctx_->compression_level());
249 ctx_->sent_initial_metadata_ =
true;
253 finish_buf_.ServerSendStatus(ctx_->trailing_metadata_,
254 finish_buf_.SendMessage(msg));
256 finish_buf_.ServerSendStatus(ctx_->trailing_metadata_, status);
275 finish_buf_.set_output_tag(tag);
276 if (!ctx_->sent_initial_metadata_) {
277 finish_buf_.SendInitialMetadata(ctx_->initial_metadata_,
278 ctx_->initial_metadata_flags());
279 if (ctx_->compression_level_set()) {
280 finish_buf_.set_compression_level(ctx_->compression_level());
282 ctx_->sent_initial_metadata_ =
true;
284 finish_buf_.ServerSendStatus(ctx_->trailing_metadata_, status);
305 class default_delete<
grpc::ClientAsyncResponseReader<R>> {
310 class default_delete<
grpc::ClientAsyncResponseReaderInterface<R>> {
316 #endif // GRPCPP_IMPL_CODEGEN_ASYNC_UNARY_CALL_H void FinishWithError(const 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:273
virtual ~ClientAsyncResponseReaderInterface()
Definition: async_unary_call.h:40
virtual void Finish(R *msg, 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...
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:138
virtual void StartCall()=0
Start the call that was set up by the constructor, but only if the constructor was invoked through th...
Definition: async_unary_call.h:74
void Finish(const W &msg, const 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:241
Primary implementation of CallOpSetInterface.
Definition: call.h:619
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:113
Definition: async_unary_call.h:303
virtual void ReadInitialMetadata(void *tag)=0
Request notification of the reading of initial metadata.
Definition: service_type.h:39
grpc_call * call() const
Definition: call.h:680
Async API for client-side unary RPCs, where the message response received from the server is of type ...
Definition: async_unary_call.h:98
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:162
void operator()(void *p)
Definition: async_unary_call.h:307
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_unary_call.h:213
An interface relevant for async client side unary RPCs (which send one request message to a server an...
Definition: async_unary_call.h:38
void operator()(void *p)
Definition: async_unary_call.h:312
static ClientAsyncResponseReader< R > * Create(ChannelInterface *channel, CompletionQueue *cq, const ::grpc::internal::RpcMethod &method, ClientContext *context, const W &request, bool start)
Start a call and write the request out if start is set.
Definition: async_unary_call.h:83
An Alarm posts the user provided tag to its associated completion queue upon expiry or cancellation...
Definition: alarm.h:31
Codegen interface for grpc::Channel.
Definition: channel_interface.h:55
CoreCodegenInterface * g_core_codegen_interface
Definition: call.h:46
void ReadInitialMetadata(void *tag) override
See ClientAsyncResponseReaderInterface::ReadInitialMetadata for semantics.
Definition: async_unary_call.h:125
Definition: byte_buffer.h:41
A ServerContext allows the person implementing a service handler to:
Definition: server_context.h:96
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:94
bool ok() const
Is the status OK?
Definition: status.h:118
ServerAsyncResponseWriter(ServerContext *ctx)
Definition: async_unary_call.h:203
Did it work? If it didn't, why?
Definition: status.h:31
Async server-side API for handling unary calls, where the single response message sent to the client ...
Definition: async_unary_call.h:200
void Finish(R *msg, Status *status, void *tag) override
See ClientAysncResponseReaderInterface::Finish for semantics.
Definition: async_unary_call.h:140
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:676
Straightforward wrapping of the C call object.
Definition: call.h:660