Go to the documentation of this file.
18 #ifndef GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_IMPL_H
19 #define GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_IMPL_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);
264 bool start,
void* tag)
265 : context_(context), call_(call), started_(start) {
268 init_ops_.ClientSendClose();
270 StartCallInternal(tag);
276 void StartCallInternal(
void* tag) {
277 init_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
278 context_->initial_metadata_flags());
279 init_ops_.set_output_tag(tag);
331 const ::grpc::internal::RpcMethod& method,
333 R* response,
bool start,
void* tag) {
349 static void operator delete(
void* , std::size_t size) {
363 StartCallInternal(tag);
377 meta_ops_.set_output_tag(tag);
378 meta_ops_.RecvInitialMetadata(context_);
382 void Write(
const W& msg,
void* tag)
override {
384 write_ops_.set_output_tag(tag);
392 write_ops_.set_output_tag(tag);
395 write_ops_.ClientSendClose();
404 write_ops_.set_output_tag(tag);
405 write_ops_.ClientSendClose();
418 finish_ops_.set_output_tag(tag);
419 if (!context_->initial_metadata_received_) {
420 finish_ops_.RecvInitialMetadata(context_);
422 finish_ops_.ClientRecvStatus(context_, status);
431 bool start,
void* tag)
432 : context_(context), call_(call), started_(start) {
433 finish_ops_.RecvMessage(response);
434 finish_ops_.AllowNoMessage();
436 StartCallInternal(tag);
442 void StartCallInternal(
void* tag) {
443 write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
444 context_->initial_metadata_flags());
447 if (!context_->initial_metadata_corked_) {
448 write_ops_.set_output_tag(tag);
471 template <
class W,
class R>
485 template <
class W,
class R>
497 const ::grpc::internal::RpcMethod& method,
512 template <
class W,
class R>
517 static void operator delete(
void* , std::size_t size) {
531 StartCallInternal(tag);
545 meta_ops_.set_output_tag(tag);
546 meta_ops_.RecvInitialMetadata(context_);
550 void Read(R* msg,
void* tag)
override {
552 read_ops_.set_output_tag(tag);
553 if (!context_->initial_metadata_received_) {
554 read_ops_.RecvInitialMetadata(context_);
556 read_ops_.RecvMessage(msg);
560 void Write(
const W& msg,
void* tag)
override {
562 write_ops_.set_output_tag(tag);
570 write_ops_.set_output_tag(tag);
573 write_ops_.ClientSendClose();
582 write_ops_.set_output_tag(tag);
583 write_ops_.ClientSendClose();
593 finish_ops_.set_output_tag(tag);
594 if (!context_->initial_metadata_received_) {
595 finish_ops_.RecvInitialMetadata(context_);
597 finish_ops_.ClientRecvStatus(context_, status);
606 : context_(context), call_(call), started_(start) {
608 StartCallInternal(tag);
614 void StartCallInternal(
void* tag) {
615 write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
616 context_->initial_metadata_flags());
619 if (!context_->initial_metadata_corked_) {
620 write_ops_.set_output_tag(tag);
642 template <
class W,
class R>
699 template <
class W,
class R>
703 : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
713 meta_ops_.set_output_tag(tag);
714 meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
715 ctx_->initial_metadata_flags());
719 ctx_->sent_initial_metadata_ =
true;
723 void Read(R* msg,
void* tag)
override {
724 read_ops_.set_output_tag(tag);
725 read_ops_.RecvMessage(msg);
741 finish_ops_.set_output_tag(tag);
742 if (!ctx_->sent_initial_metadata_) {
743 finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
744 ctx_->initial_metadata_flags());
748 ctx_->sent_initial_metadata_ =
true;
752 finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_,
753 finish_ops_.SendMessage(msg));
755 finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
771 finish_ops_.set_output_tag(tag);
772 if (!ctx_->sent_initial_metadata_) {
773 finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
774 ctx_->initial_metadata_flags());
778 ctx_->sent_initial_metadata_ =
true;
780 finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
850 : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
862 meta_ops_.set_output_tag(tag);
863 meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
864 ctx_->initial_metadata_flags());
868 ctx_->sent_initial_metadata_ =
true;
872 void Write(
const W& msg,
void* tag)
override {
873 write_ops_.set_output_tag(tag);
874 EnsureInitialMetadataSent(&write_ops_);
881 write_ops_.set_output_tag(tag);
886 EnsureInitialMetadataSent(&write_ops_);
904 write_ops_.set_output_tag(tag);
905 EnsureInitialMetadataSent(&write_ops_);
908 write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
924 finish_ops_.set_output_tag(tag);
925 EnsureInitialMetadataSent(&finish_ops_);
926 finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
934 void EnsureInitialMetadataSent(T* ops) {
935 if (!ctx_->sent_initial_metadata_) {
936 ops->SendInitialMetadata(&ctx_->initial_metadata_,
937 ctx_->initial_metadata_flags());
941 ctx_->sent_initial_metadata_ =
true;
959 template <
class W,
class R>
1011 template <
class W,
class R>
1016 : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
1028 meta_ops_.set_output_tag(tag);
1029 meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
1030 ctx_->initial_metadata_flags());
1034 ctx_->sent_initial_metadata_ =
true;
1038 void Read(R* msg,
void* tag)
override {
1039 read_ops_.set_output_tag(tag);
1040 read_ops_.RecvMessage(msg);
1044 void Write(
const W& msg,
void* tag)
override {
1045 write_ops_.set_output_tag(tag);
1046 EnsureInitialMetadataSent(&write_ops_);
1053 write_ops_.set_output_tag(tag);
1057 EnsureInitialMetadataSent(&write_ops_);
1075 write_ops_.set_output_tag(tag);
1076 EnsureInitialMetadataSent(&write_ops_);
1079 write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
1095 finish_ops_.set_output_tag(tag);
1096 EnsureInitialMetadataSent(&finish_ops_);
1098 finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
1108 void EnsureInitialMetadataSent(T* ops) {
1109 if (!ctx_->sent_initial_metadata_) {
1110 ops->SendInitialMetadata(&ctx_->initial_metadata_,
1111 ctx_->initial_metadata_flags());
1115 ctx_->sent_initial_metadata_ =
true;
1134 #endif // GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_IMPL_H
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,...
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream_impl.h:382
Definition: service_type.h:41
Definition: call_op_set.h:617
void WritesDone(void *tag) override
Signal the client is done with the writes (half-close the client stream).
Definition: async_stream_impl.h:580
Definition: call_op_set.h:524
Definition: call_op_set.h:652
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream_impl.h:723
Primary implementation of CallOpSetInterface.
Definition: call_op_set.h:849
Definition: call_op_set.h:286
grpc_compression_level compression_level() const
Return the compression algorithm to be used by the server call.
Definition: server_context_impl.h:215
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:161
::grpc_impl::ClientAsyncWriter< W > ClientAsyncWriter
Definition: async_stream.h:49
virtual void * grpc_call_arena_alloc(grpc_call *call, size_t length)=0
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream_impl.h:872
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.
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_impl.h:390
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,...
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_impl.h:360
void Finish(const ::grpc::Status &status, void *tag) override
See the ServerAsyncWriterInterface.Finish method for semantics.
Definition: async_stream_impl.h:923
::grpc_impl::ClientAsyncReader< R > ClientAsyncReader
Definition: async_stream.h:43
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_impl.h:1073
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream_impl.h:373
Common interface for client side asynchronous writing.
Definition: async_stream_impl.h:302
void Finish(const W &msg, const ::grpc::Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream_impl.h:740
Straightforward wrapping of the C call object.
Definition: call.h:38
bool compression_level_set() const
Return a bool indicating whether the compression level for this call has been set (either implicitly ...
Definition: server_context_impl.h:230
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream_impl.h:1044
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_impl.h:880
::grpc_impl::Server Server
Definition: server.h:26
Server-side interface for asynchronous bi-directional streaming.
Definition: async_stream_impl.h:960
virtual ~AsyncWriterInterface()
Definition: async_stream_impl.h:105
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 ReadInitialMetadata(void *tag)=0
Request notification of the reading of the initial metadata.
Did it work? If it didn't, why?
Definition: status.h:31
Async API on the client side for doing client-streaming RPCs, where the outgoing message stream going...
Definition: async_stream_impl.h:346
A ServerContext or CallbackServerContext allows the code implementing a service handler to:
Definition: server_context_impl.h:510
Definition: async_stream_impl.h:170
virtual void Finish(const ::grpc::Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain status code.
ServerAsyncReaderWriter(::grpc_impl::ServerContext *ctx)
Definition: async_stream_impl.h:1015
An interface that yields a sequence of messages of type R.
Definition: async_stream_impl.h:81
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream_impl.h:550
void FinishWithError(const ::grpc::Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream_impl.h:769
Common interface for all client side asynchronous streaming.
Definition: async_stream_impl.h:32
virtual void Write(const W &msg, void *tag)=0
Request the writing of msg with identifying tag tag.
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_impl.h:528
Async client-side API for doing server-streaming RPCs, where the incoming message stream coming from ...
Definition: async_stream_impl.h:197
Definition: async_stream_impl.h:486
Definition: async_stream_impl.h:643
ServerAsyncWriter(::grpc_impl::ServerContext *ctx)
Definition: async_stream_impl.h:849
static ClientAsyncReaderWriter< W, R > * Create(::grpc::ChannelInterface *channel, ::grpc_impl::CompletionQueue *cq, const ::grpc::internal::RpcMethod &method, ::grpc_impl::ClientContext *context, bool start, void *tag)
Create a stream object.
Definition: async_stream_impl.h:495
Codegen interface for grpc::Channel.
Definition: channel_interface.h:74
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...
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream_impl.h:859
static ClientAsyncReader< R > * Create(::grpc::ChannelInterface *channel, ::grpc_impl::CompletionQueue *cq, const ::grpc::internal::RpcMethod &method, ::grpc_impl::ClientContext *context, const W &request, bool start, void *tag)
Create a stream object.
Definition: async_stream_impl.h:180
Definition: async_stream_impl.h:164
Async client-side interface for bi-directional streaming, where the outgoing message stream going to ...
Definition: async_stream_impl.h:513
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream_impl.h:1038
::google::protobuf::util::Status Status
Definition: config_protobuf.h:90
void Finish(::grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream_impl.h:416
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream_impl.h:234
Per-message write options.
Definition: call_op_set.h:79
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue_impl.h:103
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream_impl.h:1025
Async client-side interface for bi-directional streaming, where the client-to-server message stream h...
Definition: async_stream_impl.h:472
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:68
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_impl.h:1052
grpc_call * call() const
Definition: call.h:72
void Finish(::grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream_impl.h:591
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_impl.h:211
virtual void WritesDone(void *tag)=0
Signal the client is done with the writes (half-close the client stream).
Definition: call_op_set.h:767
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:122
Async server-side API for doing bidirectional streaming RPCs, where the incoming message stream comin...
Definition: async_stream_impl.h:1012
Async server-side API for doing client-streaming RPCs, where the incoming message stream from the cli...
Definition: async_stream_impl.h:700
::grpc_impl::ClientAsyncReaderWriter< W, R > ClientAsyncReaderWriter
Definition: async_stream.h:56
void WritesDone(void *tag) override
Signal the client is done with the writes (half-close the client stream).
Definition: async_stream_impl.h:402
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream_impl.h:710
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_impl.h:156
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm_impl.h:33
void Finish(const ::grpc::Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.Finish method for semantics.
Definition: async_stream_impl.h:1094
ServerAsyncReader(::grpc_impl::ServerContext *ctx)
Definition: async_stream_impl.h:702
Definition: async_stream_impl.h:315
virtual void Read(R *msg, void *tag)=0
Read a message of type R into msg.
virtual ~ClientAsyncStreamingInterface()
Definition: async_stream_impl.h:34
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 ...
CoreCodegenInterface * g_core_codegen_interface
Definition: completion_queue_impl.h:93
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:146
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_impl.h:902
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream_impl.h:225
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:186
A ClientContext allows the person implementing a service client to:
Definition: client_context_impl.h:184
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics of this method.
Definition: async_stream_impl.h:541
Definition: byte_buffer.h:58
void Finish(::grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream_impl.h:249
virtual ~AsyncReaderInterface()
Definition: async_stream_impl.h:83
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.
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_impl.h:568
virtual void WritesDone(void *tag)=0
Signal the client is done with the writes (half-close the client stream).
An interface that can be fed a sequence of messages of type W.
Definition: async_stream_impl.h:103
Async server-side API for doing server streaming RPCs, where the outgoing message stream from the ser...
Definition: async_stream_impl.h:847
static ClientAsyncWriter< W > * Create(::grpc::ChannelInterface *channel, ::grpc_impl::CompletionQueue *cq, const ::grpc::internal::RpcMethod &method, ::grpc_impl::ClientContext *context, R *response, bool start, void *tag)
Create a stream object.
Definition: async_stream_impl.h:329
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream_impl.h:560
Definition: async_stream_impl.h:799