18 #ifndef GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H
19 #define GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H
98 virtual void Read(R* msg,
void* tag) = 0;
119 virtual void Write(
const W& msg,
void* tag) = 0;
182 const ::grpc::internal::RpcMethod& method,
184 const W& request,
bool start,
void* tag) {
200 static void operator delete(
void* , std::size_t size) {
214 StartCallInternal(tag);
229 meta_ops_.set_output_tag(tag);
230 meta_ops_.RecvInitialMetadata(context_);
234 void Read(R* msg,
void* tag)
override {
236 read_ops_.set_output_tag(tag);
237 if (!context_->initial_metadata_received_) {
238 read_ops_.RecvInitialMetadata(context_);
240 read_ops_.RecvMessage(msg);
251 finish_ops_.set_output_tag(tag);
252 if (!context_->initial_metadata_received_) {
253 finish_ops_.RecvInitialMetadata(context_);
255 finish_ops_.ClientRecvStatus(context_, status);
263 const W& request,
bool start,
void* tag)
264 : context_(context), call_(call), started_(start) {
267 init_ops_.ClientSendClose();
269 StartCallInternal(tag);
275 void StartCallInternal(
void* tag) {
276 init_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
277 context_->initial_metadata_flags());
278 init_ops_.set_output_tag(tag);
330 const ::grpc::internal::RpcMethod& method,
332 R* response,
bool start,
void* tag) {
348 static void operator delete(
void* , std::size_t size) {
362 StartCallInternal(tag);
376 meta_ops_.set_output_tag(tag);
377 meta_ops_.RecvInitialMetadata(context_);
381 void Write(
const W& msg,
void* tag)
override {
383 write_ops_.set_output_tag(tag);
391 write_ops_.set_output_tag(tag);
394 write_ops_.ClientSendClose();
403 write_ops_.set_output_tag(tag);
404 write_ops_.ClientSendClose();
417 finish_ops_.set_output_tag(tag);
418 if (!context_->initial_metadata_received_) {
419 finish_ops_.RecvInitialMetadata(context_);
421 finish_ops_.ClientRecvStatus(context_, status);
429 R* response,
bool start,
void* tag)
430 : context_(context), call_(call), started_(start) {
431 finish_ops_.RecvMessage(response);
432 finish_ops_.AllowNoMessage();
434 StartCallInternal(tag);
440 void StartCallInternal(
void* tag) {
441 write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
442 context_->initial_metadata_flags());
445 if (!context_->initial_metadata_corked_) {
446 write_ops_.set_output_tag(tag);
469 template <
class W,
class R>
483 template <
class W,
class R>
496 bool start,
void* tag) {
510 template <
class W,
class R>
515 static void operator delete(
void* , std::size_t size) {
529 StartCallInternal(tag);
543 meta_ops_.set_output_tag(tag);
544 meta_ops_.RecvInitialMetadata(context_);
548 void Read(R* msg,
void* tag)
override {
550 read_ops_.set_output_tag(tag);
551 if (!context_->initial_metadata_received_) {
552 read_ops_.RecvInitialMetadata(context_);
554 read_ops_.RecvMessage(msg);
558 void Write(
const W& msg,
void* tag)
override {
560 write_ops_.set_output_tag(tag);
568 write_ops_.set_output_tag(tag);
571 write_ops_.ClientSendClose();
580 write_ops_.set_output_tag(tag);
581 write_ops_.ClientSendClose();
591 finish_ops_.set_output_tag(tag);
592 if (!context_->initial_metadata_received_) {
593 finish_ops_.RecvInitialMetadata(context_);
595 finish_ops_.ClientRecvStatus(context_, status);
603 : context_(context), call_(call), started_(start) {
605 StartCallInternal(tag);
611 void StartCallInternal(
void* tag) {
612 write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
613 context_->initial_metadata_flags());
616 if (!context_->initial_metadata_corked_) {
617 write_ops_.set_output_tag(tag);
639 template <
class W,
class R>
696 template <
class W,
class R>
700 : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
710 meta_ops_.set_output_tag(tag);
711 meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
712 ctx_->initial_metadata_flags());
716 ctx_->sent_initial_metadata_ =
true;
720 void Read(R* msg,
void* tag)
override {
721 read_ops_.set_output_tag(tag);
722 read_ops_.RecvMessage(msg);
738 finish_ops_.set_output_tag(tag);
739 if (!ctx_->sent_initial_metadata_) {
740 finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
741 ctx_->initial_metadata_flags());
745 ctx_->sent_initial_metadata_ =
true;
749 finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_,
750 finish_ops_.SendMessage(msg));
752 finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
768 finish_ops_.set_output_tag(tag);
769 if (!ctx_->sent_initial_metadata_) {
770 finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
771 ctx_->initial_metadata_flags());
775 ctx_->sent_initial_metadata_ =
true;
777 finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
847 : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
859 meta_ops_.set_output_tag(tag);
860 meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
861 ctx_->initial_metadata_flags());
865 ctx_->sent_initial_metadata_ =
true;
869 void Write(
const W& msg,
void* tag)
override {
870 write_ops_.set_output_tag(tag);
871 EnsureInitialMetadataSent(&write_ops_);
878 write_ops_.set_output_tag(tag);
883 EnsureInitialMetadataSent(&write_ops_);
901 write_ops_.set_output_tag(tag);
902 EnsureInitialMetadataSent(&write_ops_);
905 write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
921 finish_ops_.set_output_tag(tag);
922 EnsureInitialMetadataSent(&finish_ops_);
923 finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
931 void EnsureInitialMetadataSent(T* ops) {
932 if (!ctx_->sent_initial_metadata_) {
933 ops->SendInitialMetadata(&ctx_->initial_metadata_,
934 ctx_->initial_metadata_flags());
938 ctx_->sent_initial_metadata_ =
true;
956 template <
class W,
class R>
1008 template <
class W,
class R>
1013 : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
1025 meta_ops_.set_output_tag(tag);
1026 meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
1027 ctx_->initial_metadata_flags());
1031 ctx_->sent_initial_metadata_ =
true;
1035 void Read(R* msg,
void* tag)
override {
1036 read_ops_.set_output_tag(tag);
1037 read_ops_.RecvMessage(msg);
1041 void Write(
const W& msg,
void* tag)
override {
1042 write_ops_.set_output_tag(tag);
1043 EnsureInitialMetadataSent(&write_ops_);
1050 write_ops_.set_output_tag(tag);
1054 EnsureInitialMetadataSent(&write_ops_);
1072 write_ops_.set_output_tag(tag);
1073 EnsureInitialMetadataSent(&write_ops_);
1076 write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
1092 finish_ops_.set_output_tag(tag);
1093 EnsureInitialMetadataSent(&finish_ops_);
1095 finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
1100 friend class ::grpc::Server;
1105 void EnsureInitialMetadataSent(T* ops) {
1106 if (!ctx_->sent_initial_metadata_) {
1107 ops->SendInitialMetadata(&ctx_->initial_metadata_,
1108 ctx_->initial_metadata_flags());
1112 ctx_->sent_initial_metadata_ =
true;
Codegen interface for grpc::Channel.
Definition: channel_interface.h:71
Async client-side API for doing server-streaming RPCs, where the incoming message stream coming from ...
Definition: async_stream.h:197
void StartCall(void *tag) override
Start the call that was set up by the constructor, but only if the constructor was invoked through th...
Definition: async_stream.h:211
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:234
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:225
void Finish(::grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:249
Definition: async_stream.h:166
Async client-side interface for bi-directional streaming, where the outgoing message stream going to ...
Definition: async_stream.h:512
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:558
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics of this method.
Definition: async_stream.h:539
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:548
void Write(const W &msg, ::grpc::WriteOptions options, void *tag) override
Request the writing of msg using WriteOptions options with identifying tag tag.
Definition: async_stream.h:566
void Finish(::grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:589
void StartCall(void *tag) override
Start the call that was set up by the constructor, but only if the constructor was invoked through th...
Definition: async_stream.h:526
void WritesDone(void *tag) override
Signal the client is done with the writes (half-close the client stream).
Definition: async_stream.h:578
Async client-side interface for bi-directional streaming, where the client-to-server message stream h...
Definition: async_stream.h:473
virtual void WritesDone(void *tag)=0
Signal the client is done with the writes (half-close the client stream).
Async API on the client side for doing client-streaming RPCs, where the outgoing message stream going...
Definition: async_stream.h:345
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:372
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:381
void Write(const W &msg, ::grpc::WriteOptions options, void *tag) override
Request the writing of msg using WriteOptions options with identifying tag tag.
Definition: async_stream.h:389
void StartCall(void *tag) override
Start the call that was set up by the constructor, but only if the constructor was invoked through th...
Definition: async_stream.h:359
void Finish(::grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:415
void WritesDone(void *tag) override
Signal the client is done with the writes (half-close the client stream).
Definition: async_stream.h:401
Common interface for client side asynchronous writing.
Definition: async_stream.h:303
virtual void WritesDone(void *tag)=0
Signal the client is done with the writes (half-close the client stream).
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 doing client-streaming RPCs, where the incoming message stream from the cli...
Definition: async_stream.h:697
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:707
void Finish(const W &msg, const ::grpc::Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:737
ServerAsyncReader(::grpc::ServerContext *ctx)
Definition: async_stream.h:699
void FinishWithError(const ::grpc::Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:766
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:720
Definition: async_stream.h:642
virtual void Finish(const W &msg, const ::grpc::Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain status code and also send out msg response ...
virtual void FinishWithError(const ::grpc::Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain non-OK status code.
Async server-side API for doing bidirectional streaming RPCs, where the incoming message stream comin...
Definition: async_stream.h:1010
void WriteAndFinish(const W &msg, ::grpc::WriteOptions options, const ::grpc::Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.WriteAndFinish method for semantics.
Definition: async_stream.h:1070
void Write(const W &msg, ::grpc::WriteOptions options, void *tag) override
Request the writing of msg using WriteOptions options with identifying tag tag.
Definition: async_stream.h:1049
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:1022
void Finish(const ::grpc::Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.Finish method for semantics.
Definition: async_stream.h:1091
ServerAsyncReaderWriter(::grpc::ServerContext *ctx)
Definition: async_stream.h:1012
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:1041
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:1035
Server-side interface for asynchronous bi-directional streaming.
Definition: async_stream.h:960
virtual void Finish(const ::grpc::Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain status code.
virtual void WriteAndFinish(const W &msg, ::grpc::WriteOptions options, const ::grpc::Status &status, void *tag)=0
Request the writing of msg and coalesce it with trailing metadata which contains status,...
Async server-side API for doing server streaming RPCs, where the outgoing message stream from the ser...
Definition: async_stream.h:844
ServerAsyncWriter(::grpc::ServerContext *ctx)
Definition: async_stream.h:846
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:869
void Write(const W &msg, ::grpc::WriteOptions options, void *tag) override
Request the writing of msg using WriteOptions options with identifying tag tag.
Definition: async_stream.h:877
void WriteAndFinish(const W &msg, ::grpc::WriteOptions options, const ::grpc::Status &status, void *tag) override
See the ServerAsyncWriterInterface.WriteAndFinish method for semantics.
Definition: async_stream.h:899
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:856
void Finish(const ::grpc::Status &status, void *tag) override
See the ServerAsyncWriterInterface.Finish method for semantics.
Definition: async_stream.h:920
Definition: async_stream.h:798
virtual void Finish(const ::grpc::Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain status code.
virtual void WriteAndFinish(const W &msg, ::grpc::WriteOptions options, const ::grpc::Status &status, void *tag)=0
Request the writing of msg and coalesce it with trailing metadata which contains status,...
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
Per-message write options.
Definition: call_op_set.h:79
bool is_last_message() const
Get value for the flag indicating that this is the last message, and should be coalesced with trailin...
Definition: call_op_set.h:181
WriteOptions & set_last_message()
last-message bit: indicates this is the last message in a stream client-side: makes Write the equival...
Definition: call_op_set.h:156
WriteOptions & set_buffer_hint()
Sets flag indicating that the write may be buffered and need not go out on the wire immediately.
Definition: call_op_set.h:117
An interface that yields a sequence of messages of type R.
Definition: async_stream.h:81
virtual ~AsyncReaderInterface()
Definition: async_stream.h:83
virtual void Read(R *msg, void *tag)=0
Read a message of type R into msg.
An interface that can be fed a sequence of messages of type W.
Definition: async_stream.h:103
virtual ~AsyncWriterInterface()
Definition: async_stream.h:105
void WriteLast(const W &msg, ::grpc::WriteOptions options, void *tag)
Request the writing of msg and coalesce it with the writing of trailing metadata, using WriteOptions ...
Definition: async_stream.h:156
virtual void Write(const W &msg, ::grpc::WriteOptions options, void *tag)=0
Request the writing of msg using WriteOptions options with identifying tag tag.
virtual void Write(const W &msg, void *tag)=0
Request the writing of msg with identifying tag tag.
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
Definition: call_op_set.h:619
Definition: call_op_set.h:526
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
Definition: async_stream.h:170
static ClientAsyncReader< R > * Create(::grpc::ChannelInterface *channel, ::grpc::CompletionQueue *cq, const ::grpc::internal::RpcMethod &method, ::grpc::ClientContext *context, const W &request, bool start, void *tag)
Create a stream object.
Definition: async_stream.h:180
Definition: async_stream.h:484
static ClientAsyncReaderWriter< W, R > * Create(::grpc::ChannelInterface *channel, ::grpc::CompletionQueue *cq, const ::grpc::internal::RpcMethod &method, ::grpc::ClientContext *context, bool start, void *tag)
Create a stream object.
Definition: async_stream.h:493
Common interface for all client side asynchronous streaming.
Definition: async_stream.h:32
virtual void Finish(::grpc::Status *status, void *tag)=0
Indicate that the stream is to be finished and request notification for when the call has been ended.
virtual void StartCall(void *tag)=0
Start the call that was set up by the constructor, but only if the constructor was invoked through th...
virtual ~ClientAsyncStreamingInterface()
Definition: async_stream.h:34
virtual void ReadInitialMetadata(void *tag)=0
Request notification of the reading of the initial metadata.
Definition: async_stream.h:314
static ClientAsyncWriter< W > * Create(::grpc::ChannelInterface *channel, ::grpc::CompletionQueue *cq, const ::grpc::internal::RpcMethod &method, ::grpc::ClientContext *context, R *response, bool start, void *tag)
Create a stream object.
Definition: async_stream.h:328
Definition: service_type.h:37
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:146
::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