19 #ifndef GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H 20 #define GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H 31 class CompletionQueue;
101 virtual void Read(R* msg,
void* tag) = 0;
119 virtual void Write(
const W& msg,
void* tag) = 0;
133 virtual void Write(
const W& msg,
WriteOptions options,
void* tag) = 0;
176 const ::grpc::internal::RpcMethod& method,
178 bool start,
void* tag) {
194 static void operator delete(
void* ptr, std::size_t size) {
201 StartCallInternal(tag);
216 meta_ops_.set_output_tag(tag);
217 meta_ops_.RecvInitialMetadata(context_);
218 call_.PerformOps(&meta_ops_);
221 void Read(R* msg,
void* tag)
override {
223 read_ops_.set_output_tag(tag);
224 if (!context_->initial_metadata_received_) {
225 read_ops_.RecvInitialMetadata(context_);
227 read_ops_.RecvMessage(msg);
228 call_.PerformOps(&read_ops_);
238 finish_ops_.set_output_tag(tag);
239 if (!context_->initial_metadata_received_) {
240 finish_ops_.RecvInitialMetadata(context_);
242 finish_ops_.ClientRecvStatus(context_, status);
243 call_.PerformOps(&finish_ops_);
250 const W& request,
bool start,
void* tag)
251 : context_(context), call_(call), started_(start) {
254 init_ops_.ClientSendClose();
256 StartCallInternal(tag);
258 assert(tag ==
nullptr);
262 void StartCallInternal(
void* tag) {
263 init_ops_.SendInitialMetadata(context_->send_initial_metadata_,
264 context_->initial_metadata_flags());
265 init_ops_.set_output_tag(tag);
266 call_.PerformOps(&init_ops_);
296 virtual void WritesDone(
void* tag) = 0;
317 const ::grpc::internal::RpcMethod& method,
319 bool start,
void* tag) {
335 static void operator delete(
void* ptr, std::size_t size) {
342 StartCallInternal(tag);
356 meta_ops_.set_output_tag(tag);
357 meta_ops_.RecvInitialMetadata(context_);
358 call_.PerformOps(&meta_ops_);
361 void Write(
const W& msg,
void* tag)
override {
363 write_ops_.set_output_tag(tag);
366 call_.PerformOps(&write_ops_);
371 write_ops_.set_output_tag(tag);
374 write_ops_.ClientSendClose();
378 call_.PerformOps(&write_ops_);
383 write_ops_.set_output_tag(tag);
384 write_ops_.ClientSendClose();
385 call_.PerformOps(&write_ops_);
397 finish_ops_.set_output_tag(tag);
398 if (!context_->initial_metadata_received_) {
399 finish_ops_.RecvInitialMetadata(context_);
401 finish_ops_.ClientRecvStatus(context_, status);
402 call_.PerformOps(&finish_ops_);
409 R* response,
bool start,
void* tag)
410 : context_(context), call_(call), started_(start) {
411 finish_ops_.RecvMessage(response);
412 finish_ops_.AllowNoMessage();
414 StartCallInternal(tag);
416 assert(tag ==
nullptr);
420 void StartCallInternal(
void* tag) {
421 write_ops_.SendInitialMetadata(context_->send_initial_metadata_,
422 context_->initial_metadata_flags());
425 if (!context_->initial_metadata_corked_) {
426 write_ops_.set_output_tag(tag);
427 call_.PerformOps(&write_ops_);
449 template <
class W,
class R>
459 virtual void WritesDone(
void* tag) = 0;
463 template <
class W,
class R>
475 const ::grpc::internal::RpcMethod& method,
ClientContext* context,
476 bool start,
void* tag) {
490 template <
class W,
class R>
495 static void operator delete(
void* ptr, std::size_t size) {
502 StartCallInternal(tag);
516 meta_ops_.set_output_tag(tag);
517 meta_ops_.RecvInitialMetadata(context_);
518 call_.PerformOps(&meta_ops_);
521 void Read(R* msg,
void* tag)
override {
523 read_ops_.set_output_tag(tag);
524 if (!context_->initial_metadata_received_) {
525 read_ops_.RecvInitialMetadata(context_);
527 read_ops_.RecvMessage(msg);
528 call_.PerformOps(&read_ops_);
531 void Write(
const W& msg,
void* tag)
override {
533 write_ops_.set_output_tag(tag);
536 call_.PerformOps(&write_ops_);
541 write_ops_.set_output_tag(tag);
544 write_ops_.ClientSendClose();
548 call_.PerformOps(&write_ops_);
553 write_ops_.set_output_tag(tag);
554 write_ops_.ClientSendClose();
555 call_.PerformOps(&write_ops_);
564 finish_ops_.set_output_tag(tag);
565 if (!context_->initial_metadata_received_) {
566 finish_ops_.RecvInitialMetadata(context_);
568 finish_ops_.ClientRecvStatus(context_, status);
569 call_.PerformOps(&finish_ops_);
575 bool start,
void* tag)
576 : context_(context), call_(call), started_(start) {
578 StartCallInternal(tag);
580 assert(tag ==
nullptr);
584 void StartCallInternal(
void* tag) {
585 write_ops_.SendInitialMetadata(context_->send_initial_metadata_,
586 context_->initial_metadata_flags());
589 if (!context_->initial_metadata_corked_) {
590 write_ops_.set_output_tag(tag);
591 call_.PerformOps(&write_ops_);
612 template <
class W,
class R>
636 virtual void Finish(
const W& msg,
const Status& status,
void* tag) = 0;
656 virtual void FinishWithError(
const Status& status,
void* tag) = 0;
662 template <
class W,
class R>
666 : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
676 meta_ops_.set_output_tag(tag);
677 meta_ops_.SendInitialMetadata(ctx_->initial_metadata_,
678 ctx_->initial_metadata_flags());
679 if (ctx_->compression_level_set()) {
680 meta_ops_.set_compression_level(ctx_->compression_level());
682 ctx_->sent_initial_metadata_ =
true;
683 call_.PerformOps(&meta_ops_);
686 void Read(R* msg,
void* tag)
override {
687 read_ops_.set_output_tag(tag);
688 read_ops_.RecvMessage(msg);
689 call_.PerformOps(&read_ops_);
701 finish_ops_.set_output_tag(tag);
702 if (!ctx_->sent_initial_metadata_) {
703 finish_ops_.SendInitialMetadata(ctx_->initial_metadata_,
704 ctx_->initial_metadata_flags());
705 if (ctx_->compression_level_set()) {
706 finish_ops_.set_compression_level(ctx_->compression_level());
708 ctx_->sent_initial_metadata_ =
true;
712 finish_ops_.ServerSendStatus(ctx_->trailing_metadata_,
713 finish_ops_.SendMessage(msg));
715 finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
717 call_.PerformOps(&finish_ops_);
728 finish_ops_.set_output_tag(tag);
729 if (!ctx_->sent_initial_metadata_) {
730 finish_ops_.SendInitialMetadata(ctx_->initial_metadata_,
731 ctx_->initial_metadata_flags());
732 if (ctx_->compression_level_set()) {
733 finish_ops_.set_compression_level(ctx_->compression_level());
735 ctx_->sent_initial_metadata_ =
true;
737 finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
738 call_.PerformOps(&finish_ops_);
778 virtual void Finish(
const Status& status,
void* tag) = 0;
791 virtual void WriteAndFinish(
const W& msg,
WriteOptions options,
792 const Status& status,
void* tag) = 0;
801 : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
813 meta_ops_.set_output_tag(tag);
814 meta_ops_.SendInitialMetadata(ctx_->initial_metadata_,
815 ctx_->initial_metadata_flags());
816 if (ctx_->compression_level_set()) {
817 meta_ops_.set_compression_level(ctx_->compression_level());
819 ctx_->sent_initial_metadata_ =
true;
820 call_.PerformOps(&meta_ops_);
823 void Write(
const W& msg,
void* tag)
override {
824 write_ops_.set_output_tag(tag);
825 EnsureInitialMetadataSent(&write_ops_);
828 call_.PerformOps(&write_ops_);
832 write_ops_.set_output_tag(tag);
837 EnsureInitialMetadataSent(&write_ops_);
840 call_.PerformOps(&write_ops_);
851 void* tag)
override {
852 write_ops_.set_output_tag(tag);
853 EnsureInitialMetadataSent(&write_ops_);
856 write_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
857 call_.PerformOps(&write_ops_);
869 finish_ops_.set_output_tag(tag);
870 EnsureInitialMetadataSent(&finish_ops_);
871 finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
872 call_.PerformOps(&finish_ops_);
879 void EnsureInitialMetadataSent(T* ops) {
880 if (!ctx_->sent_initial_metadata_) {
881 ops->SendInitialMetadata(ctx_->initial_metadata_,
882 ctx_->initial_metadata_flags());
883 if (ctx_->compression_level_set()) {
884 ops->set_compression_level(ctx_->compression_level());
886 ctx_->sent_initial_metadata_ =
true;
904 template <
class W,
class R>
929 virtual void Finish(
const Status& status,
void* tag) = 0;
942 virtual void WriteAndFinish(
const W& msg,
WriteOptions options,
943 const Status& status,
void* tag) = 0;
950 template <
class W,
class R>
955 : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
967 meta_ops_.set_output_tag(tag);
968 meta_ops_.SendInitialMetadata(ctx_->initial_metadata_,
969 ctx_->initial_metadata_flags());
970 if (ctx_->compression_level_set()) {
971 meta_ops_.set_compression_level(ctx_->compression_level());
973 ctx_->sent_initial_metadata_ =
true;
974 call_.PerformOps(&meta_ops_);
977 void Read(R* msg,
void* tag)
override {
978 read_ops_.set_output_tag(tag);
979 read_ops_.RecvMessage(msg);
980 call_.PerformOps(&read_ops_);
983 void Write(
const W& msg,
void* tag)
override {
984 write_ops_.set_output_tag(tag);
985 EnsureInitialMetadataSent(&write_ops_);
988 call_.PerformOps(&write_ops_);
992 write_ops_.set_output_tag(tag);
996 EnsureInitialMetadataSent(&write_ops_);
998 call_.PerformOps(&write_ops_);
1010 void* tag)
override {
1011 write_ops_.set_output_tag(tag);
1012 EnsureInitialMetadataSent(&write_ops_);
1015 write_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
1016 call_.PerformOps(&write_ops_);
1028 finish_ops_.set_output_tag(tag);
1029 EnsureInitialMetadataSent(&finish_ops_);
1031 finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
1032 call_.PerformOps(&finish_ops_);
1036 friend class ::grpc::Server;
1041 void EnsureInitialMetadataSent(T* ops) {
1042 if (!ctx_->sent_initial_metadata_) {
1043 ops->SendInitialMetadata(ctx_->initial_metadata_,
1044 ctx_->initial_metadata_flags());
1045 if (ctx_->compression_level_set()) {
1046 ops->set_compression_level(ctx_->compression_level());
1048 ctx_->sent_initial_metadata_ =
true;
1068 #endif // GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H Async client-side interface for bi-directional streaming, where the outgoing message stream going to ...
Definition: async_stream.h:491
virtual ~AsyncReaderInterface()
Definition: async_stream.h:86
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:686
WriteOptions & set_buffer_hint()
Sets flag indicating that the write may be buffered and need not go out on the wire immediately...
Definition: call.h:123
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:138
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:221
static ClientAsyncWriter< W > * Create(ChannelInterface *channel, CompletionQueue *cq, const ::grpc::internal::RpcMethod &method, ClientContext *context, R *response, bool start, void *tag)
Create a stream object.
Definition: async_stream.h:315
static ClientAsyncReaderWriter< W, R > * Create(ChannelInterface *channel, CompletionQueue *cq, const ::grpc::internal::RpcMethod &method, ClientContext *context, bool start, void *tag)
Create a stream object.
Definition: async_stream.h:473
WriteOptions & set_last_message()
last-message bit: indicates this is the last message in a stream client-side: makes Write the equival...
Definition: call.h:162
Primary implementation of CallOpSetInterface.
Definition: call.h:619
Async server-side API for doing bidirectional streaming RPCs, where the incoming message stream comin...
Definition: async_stream.h:951
void FinishWithError(const Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:726
void Write(const W &msg, WriteOptions options, void *tag) override
Request the writing of msg using WriteOptions options with identifying tag tag.
Definition: async_stream.h:991
void Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:562
Definition: async_stream.h:613
Definition: service_type.h:39
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 Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:236
grpc_call * call() const
Definition: call.h:680
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:162
Definition: async_stream.h:301
Definition: async_stream.h:164
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:823
Async server-side API for doing server streaming RPCs, where the outgoing message stream from the ser...
Definition: async_stream.h:798
static ClientAsyncReader< R > * Create(ChannelInterface *channel, CompletionQueue *cq, const ::grpc::internal::RpcMethod &method, ClientContext *context, const W &request, bool start, void *tag)
Create a stream object.
Definition: async_stream.h:174
void Finish(const W &msg, const Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:700
An interface that yields a sequence of messages of type R.
Definition: async_stream.h:84
void Finish(const Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.Finish method for semantics.
Definition: async_stream.h:1027
void Write(const W &msg, WriteOptions options, void *tag) override
Request the writing of msg using WriteOptions options with identifying tag tag.
Definition: async_stream.h:539
ServerAsyncReaderWriter(ServerContext *ctx)
Definition: async_stream.h:954
Definition: async_stream.h:158
Definition: async_stream.h:464
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:964
virtual void Finish(Status *status, void *tag)=0
Indicate that the stream is to be finished and request notification for when the call has been ended...
Async client-side interface for bi-directional streaming, where the client-to-server message stream h...
Definition: async_stream.h:450
An Alarm posts the user provided tag to its associated completion queue upon expiry or cancellation...
Definition: alarm.h:31
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:339
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:198
Codegen interface for grpc::Channel.
Definition: channel_interface.h:55
ServerAsyncWriter(ServerContext *ctx)
Definition: async_stream.h:800
CoreCodegenInterface * g_core_codegen_interface
Definition: call.h:46
virtual void ReadInitialMetadata(void *tag)=0
Request notification of the reading of the initial metadata.
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:810
void WriteLast(const W &msg, WriteOptions options, void *tag)
Request the writing of msg and coalesce it with the writing of trailing metadata, using WriteOptions ...
Definition: async_stream.h:150
Async API on the client side for doing client-streaming RPCs, where the outgoing message stream going...
Definition: async_stream.h:332
Server-side interface for asynchronous bi-directional streaming.
Definition: async_stream.h:905
Definition: byte_buffer.h:41
void WritesDone(void *tag) override
Signal the client is done with the writes (half-close the client stream).
Definition: async_stream.h:551
A ServerContext allows the person implementing a service handler to:
Definition: server_context.h:96
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:673
Per-message write options.
Definition: call.h:83
void Write(const W &msg, WriteOptions options, void *tag) override
Request the writing of msg using WriteOptions options with identifying tag tag.
Definition: async_stream.h:831
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:361
void WriteAndFinish(const W &msg, WriteOptions options, const Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.WriteAndFinish method for semantics.
Definition: async_stream.h:1009
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:94
virtual void * grpc_call_arena_alloc(grpc_call *call, size_t length)=0
bool ok() const
Is the status OK?
Definition: status.h:118
An interface that can be fed a sequence of messages of type W.
Definition: async_stream.h:106
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:212
virtual ~ClientAsyncStreamingInterface()
Definition: async_stream.h:37
void Write(const W &msg, WriteOptions options, void *tag) override
Request the writing of msg using WriteOptions options with identifying tag tag.
Definition: async_stream.h:369
Did it work? If it didn't, why?
Definition: status.h:31
void Finish(const Status &status, void *tag) override
See the ServerAsyncWriterInterface.Finish method for semantics.
Definition: async_stream.h:868
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics of this method...
Definition: async_stream.h:512
Definition: async_stream.h:756
void Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:395
void WritesDone(void *tag) override
Signal the client is done with the writes (half-close the client stream).
Definition: async_stream.h:381
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.h:187
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:531
Async client-side API for doing server-streaming RPCs, where the incoming message stream coming from ...
Definition: async_stream.h:191
virtual ~AsyncWriterInterface()
Definition: async_stream.h:108
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:977
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:983
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:521
void WriteAndFinish(const W &msg, WriteOptions options, const Status &status, void *tag) override
See the ServerAsyncWriterInterface.WriteAndFinish method for semantics.
Definition: async_stream.h:850
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:499
Async server-side API for doing client-streaming RPCs, where the incoming message stream from the cli...
Definition: async_stream.h:663
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:352
Common interface for all client side asynchronous streaming.
Definition: async_stream.h:35
Straightforward wrapping of the C call object.
Definition: call.h:660
ServerAsyncReader(ServerContext *ctx)
Definition: async_stream.h:665
Common interface for client side asynchronous writing.
Definition: async_stream.h:288