19 #ifndef GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H 20 #define GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H 99 virtual void Read(R* msg,
void* tag) = 0;
120 virtual void Write(
const W& msg,
void* tag) = 0;
137 virtual void Write(
const W& msg,
WriteOptions options,
void* tag) = 0;
183 const ::grpc::internal::RpcMethod& method,
185 bool start,
void* tag) {
201 static void operator delete(
void* ptr, std::size_t size) {
210 static void operator delete(
void*,
void*) { assert(0); }
215 StartCallInternal(tag);
230 meta_ops_.set_output_tag(tag);
231 meta_ops_.RecvInitialMetadata(context_);
232 call_.PerformOps(&meta_ops_);
235 void Read(R* msg,
void* tag)
override {
237 read_ops_.set_output_tag(tag);
238 if (!context_->initial_metadata_received_) {
239 read_ops_.RecvInitialMetadata(context_);
241 read_ops_.RecvMessage(msg);
242 call_.PerformOps(&read_ops_);
252 finish_ops_.set_output_tag(tag);
253 if (!context_->initial_metadata_received_) {
254 finish_ops_.RecvInitialMetadata(context_);
256 finish_ops_.ClientRecvStatus(context_, status);
257 call_.PerformOps(&finish_ops_);
264 const W& request,
bool start,
void* tag)
265 : context_(context), call_(call), started_(start) {
268 init_ops_.ClientSendClose();
270 StartCallInternal(tag);
272 assert(tag ==
nullptr);
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);
280 call_.PerformOps(&init_ops_);
310 virtual void WritesDone(
void* tag) = 0;
331 const ::grpc::internal::RpcMethod& method,
333 bool start,
void* tag) {
349 static void operator delete(
void* ptr, std::size_t size) {
358 static void operator delete(
void*,
void*) { assert(0); }
363 StartCallInternal(tag);
377 meta_ops_.set_output_tag(tag);
378 meta_ops_.RecvInitialMetadata(context_);
379 call_.PerformOps(&meta_ops_);
382 void Write(
const W& msg,
void* tag)
override {
384 write_ops_.set_output_tag(tag);
387 call_.PerformOps(&write_ops_);
392 write_ops_.set_output_tag(tag);
395 write_ops_.ClientSendClose();
399 call_.PerformOps(&write_ops_);
404 write_ops_.set_output_tag(tag);
405 write_ops_.ClientSendClose();
406 call_.PerformOps(&write_ops_);
418 finish_ops_.set_output_tag(tag);
419 if (!context_->initial_metadata_received_) {
420 finish_ops_.RecvInitialMetadata(context_);
422 finish_ops_.ClientRecvStatus(context_, status);
423 call_.PerformOps(&finish_ops_);
430 R* response,
bool start,
void* tag)
431 : context_(context), call_(call), started_(start) {
432 finish_ops_.RecvMessage(response);
433 finish_ops_.AllowNoMessage();
435 StartCallInternal(tag);
437 assert(tag ==
nullptr);
441 void StartCallInternal(
void* tag) {
442 write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
443 context_->initial_metadata_flags());
446 if (!context_->initial_metadata_corked_) {
447 write_ops_.set_output_tag(tag);
448 call_.PerformOps(&write_ops_);
470 template <
class W,
class R>
480 virtual void WritesDone(
void* tag) = 0;
484 template <
class W,
class R>
496 const ::grpc::internal::RpcMethod& method,
ClientContext* context,
497 bool start,
void* tag) {
511 template <
class W,
class R>
516 static void operator delete(
void* ptr, std::size_t size) {
525 static void operator delete(
void*,
void*) { assert(0); }
530 StartCallInternal(tag);
544 meta_ops_.set_output_tag(tag);
545 meta_ops_.RecvInitialMetadata(context_);
546 call_.PerformOps(&meta_ops_);
549 void Read(R* msg,
void* tag)
override {
551 read_ops_.set_output_tag(tag);
552 if (!context_->initial_metadata_received_) {
553 read_ops_.RecvInitialMetadata(context_);
555 read_ops_.RecvMessage(msg);
556 call_.PerformOps(&read_ops_);
559 void Write(
const W& msg,
void* tag)
override {
561 write_ops_.set_output_tag(tag);
564 call_.PerformOps(&write_ops_);
569 write_ops_.set_output_tag(tag);
572 write_ops_.ClientSendClose();
576 call_.PerformOps(&write_ops_);
581 write_ops_.set_output_tag(tag);
582 write_ops_.ClientSendClose();
583 call_.PerformOps(&write_ops_);
592 finish_ops_.set_output_tag(tag);
593 if (!context_->initial_metadata_received_) {
594 finish_ops_.RecvInitialMetadata(context_);
596 finish_ops_.ClientRecvStatus(context_, status);
597 call_.PerformOps(&finish_ops_);
603 bool start,
void* tag)
604 : context_(context), call_(call), started_(start) {
606 StartCallInternal(tag);
608 assert(tag ==
nullptr);
612 void StartCallInternal(
void* tag) {
613 write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
614 context_->initial_metadata_flags());
617 if (!context_->initial_metadata_corked_) {
618 write_ops_.set_output_tag(tag);
619 call_.PerformOps(&write_ops_);
640 template <
class W,
class R>
667 virtual void Finish(
const W& msg,
const Status& status,
void* tag) = 0;
690 virtual void FinishWithError(
const Status& status,
void* tag) = 0;
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());
713 if (ctx_->compression_level_set()) {
714 meta_ops_.set_compression_level(ctx_->compression_level());
716 ctx_->sent_initial_metadata_ =
true;
717 call_.PerformOps(&meta_ops_);
720 void Read(R* msg,
void* tag)
override {
721 read_ops_.set_output_tag(tag);
722 read_ops_.RecvMessage(msg);
723 call_.PerformOps(&read_ops_);
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());
742 if (ctx_->compression_level_set()) {
743 finish_ops_.set_compression_level(ctx_->compression_level());
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);
754 call_.PerformOps(&finish_ops_);
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());
772 if (ctx_->compression_level_set()) {
773 finish_ops_.set_compression_level(ctx_->compression_level());
775 ctx_->sent_initial_metadata_ =
true;
777 finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
778 call_.PerformOps(&finish_ops_);
821 virtual void Finish(
const Status& status,
void* tag) = 0;
837 virtual void WriteAndFinish(
const W& msg,
WriteOptions options,
838 const Status& status,
void* tag) = 0;
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());
862 if (ctx_->compression_level_set()) {
863 meta_ops_.set_compression_level(ctx_->compression_level());
865 ctx_->sent_initial_metadata_ =
true;
866 call_.PerformOps(&meta_ops_);
869 void Write(
const W& msg,
void* tag)
override {
870 write_ops_.set_output_tag(tag);
871 EnsureInitialMetadataSent(&write_ops_);
874 call_.PerformOps(&write_ops_);
878 write_ops_.set_output_tag(tag);
883 EnsureInitialMetadataSent(&write_ops_);
886 call_.PerformOps(&write_ops_);
900 void* tag)
override {
901 write_ops_.set_output_tag(tag);
902 EnsureInitialMetadataSent(&write_ops_);
905 write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
906 call_.PerformOps(&write_ops_);
921 finish_ops_.set_output_tag(tag);
922 EnsureInitialMetadataSent(&finish_ops_);
923 finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
924 call_.PerformOps(&finish_ops_);
931 void EnsureInitialMetadataSent(T* ops) {
932 if (!ctx_->sent_initial_metadata_) {
933 ops->SendInitialMetadata(&ctx_->initial_metadata_,
934 ctx_->initial_metadata_flags());
935 if (ctx_->compression_level_set()) {
936 ops->set_compression_level(ctx_->compression_level());
938 ctx_->sent_initial_metadata_ =
true;
956 template <
class W,
class R>
984 virtual void Finish(
const Status& status,
void* tag) = 0;
1000 virtual void WriteAndFinish(
const W& msg,
WriteOptions options,
1001 const Status& status,
void* tag) = 0;
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());
1028 if (ctx_->compression_level_set()) {
1029 meta_ops_.set_compression_level(ctx_->compression_level());
1031 ctx_->sent_initial_metadata_ =
true;
1032 call_.PerformOps(&meta_ops_);
1035 void Read(R* msg,
void* tag)
override {
1036 read_ops_.set_output_tag(tag);
1037 read_ops_.RecvMessage(msg);
1038 call_.PerformOps(&read_ops_);
1041 void Write(
const W& msg,
void* tag)
override {
1042 write_ops_.set_output_tag(tag);
1043 EnsureInitialMetadataSent(&write_ops_);
1046 call_.PerformOps(&write_ops_);
1050 write_ops_.set_output_tag(tag);
1054 EnsureInitialMetadataSent(&write_ops_);
1056 call_.PerformOps(&write_ops_);
1071 void* tag)
override {
1072 write_ops_.set_output_tag(tag);
1073 EnsureInitialMetadataSent(&write_ops_);
1076 write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
1077 call_.PerformOps(&write_ops_);
1092 finish_ops_.set_output_tag(tag);
1093 EnsureInitialMetadataSent(&finish_ops_);
1095 finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
1096 call_.PerformOps(&finish_ops_);
1105 void EnsureInitialMetadataSent(T* ops) {
1106 if (!ctx_->sent_initial_metadata_) {
1107 ops->SendInitialMetadata(&ctx_->initial_metadata_,
1108 ctx_->initial_metadata_flags());
1109 if (ctx_->compression_level_set()) {
1110 ops->set_compression_level(ctx_->compression_level());
1112 ctx_->sent_initial_metadata_ =
true;
1132 #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:512
virtual ~AsyncReaderInterface()
Definition: async_stream.h:84
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:720
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:125
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:145
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:235
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:329
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:494
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:164
::grpc_impl::Server Server
Definition: server.h:26
Primary implementation of CallOpSetInterface.
Definition: call_op_set.h:821
Async server-side API for doing bidirectional streaming RPCs, where the incoming message stream comin...
Definition: async_stream.h:1009
void FinishWithError(const Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:766
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:1049
void Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:590
Definition: async_stream.h:641
Definition: service_type.h:41
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:250
grpc_call * call() const
Definition: call.h:72
A ServerContext allows the person implementing a service handler to:
Definition: server_context_impl.h:114
Definition: async_stream.h:315
Definition: async_stream.h:171
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:869
Async server-side API for doing server streaming RPCs, where the outgoing message stream from the ser...
Definition: async_stream.h:844
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:181
void Finish(const W &msg, const Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:737
An interface that yields a sequence of messages of type R.
Definition: async_stream.h:82
void Finish(const Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.Finish method for semantics.
Definition: async_stream.h:1091
Definition: call_op_set.h:629
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:567
ServerAsyncReaderWriter(ServerContext *ctx)
Definition: async_stream.h:1012
Definition: async_stream.h:165
Definition: async_stream.h:485
Definition: call_op_set.h:288
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:1022
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:471
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
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:360
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:212
Codegen interface for grpc::Channel.
Definition: channel_interface.h:69
ServerAsyncWriter(ServerContext *ctx)
Definition: async_stream.h:846
CoreCodegenInterface * g_core_codegen_interface
Definition: call_op_set.h:51
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:856
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:157
Async API on the client side for doing client-streaming RPCs, where the outgoing message stream going...
Definition: async_stream.h:346
Server-side interface for asynchronous bi-directional streaming.
Definition: async_stream.h:957
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:579
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:707
Per-message write options.
Definition: call_op_set.h:85
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:877
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:382
void WriteAndFinish(const W &msg, WriteOptions options, const Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.WriteAndFinish method for semantics.
Definition: async_stream.h:1070
Definition: call_op_set.h:594
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:104
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:226
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue_impl.h:102
virtual ~ClientAsyncStreamingInterface()
Definition: async_stream.h:35
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:390
A ClientContext allows the person implementing a service client to:
Definition: client_context_impl.h:178
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:920
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics of this method...
Definition: async_stream.h:540
Definition: async_stream.h:796
void Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:416
void WritesDone(void *tag) override
Signal the client is done with the writes (half-close the client stream).
Definition: async_stream.h:402
Definition: call_op_set.h:516
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:189
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:559
Definition: call_op_set.h:744
Async client-side API for doing server-streaming RPCs, where the incoming message stream coming from ...
Definition: async_stream.h:198
virtual ~AsyncWriterInterface()
Definition: async_stream.h:106
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:1035
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:549
void WriteAndFinish(const W &msg, WriteOptions options, const Status &status, void *tag) override
See the ServerAsyncWriterInterface.WriteAndFinish method for semantics.
Definition: async_stream.h:899
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:527
Async server-side API for doing client-streaming RPCs, where the incoming message stream from the cli...
Definition: async_stream.h:697
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:373
Common interface for all client side asynchronous streaming.
Definition: async_stream.h:33
Straightforward wrapping of the C call object.
Definition: call.h:38
ServerAsyncReader(ServerContext *ctx)
Definition: async_stream.h:699
Common interface for client side asynchronous writing.
Definition: async_stream.h:302