19 #ifndef GRPCXX_IMPL_CODEGEN_ASYNC_STREAM_H
20 #define GRPCXX_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;
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);
221 void Read(R* msg,
void* tag)
override {
224 if (!context_->initial_metadata_received_) {
239 if (!context_->initial_metadata_received_) {
250 const W& request,
bool start,
void* tag)
251 : context_(context), call_(call), started_(start) {
256 StartCallInternal(tag);
258 assert(tag ==
nullptr);
262 void StartCallInternal(
void* tag) {
264 context_->initial_metadata_flags());
269 ClientContext* context_;
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);
361 void Write(
const W& msg,
void* tag)
override {
398 if (!context_->initial_metadata_received_) {
409 R* response,
bool start,
void* tag)
410 : context_(context), call_(call), started_(start) {
414 StartCallInternal(tag);
416 assert(tag ==
nullptr);
420 void StartCallInternal(
void* tag) {
422 context_->initial_metadata_flags());
425 if (!context_->initial_metadata_corked_) {
431 ClientContext* context_;
449 template <
class W,
class R>
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);
521 void Read(R* msg,
void* tag)
override {
524 if (!context_->initial_metadata_received_) {
531 void Write(
const W& msg,
void* tag)
override {
565 if (!context_->initial_metadata_received_) {
575 bool start,
void* tag)
576 : context_(context), call_(call), started_(start) {
578 StartCallInternal(tag);
580 assert(tag ==
nullptr);
584 void StartCallInternal(
void* tag) {
586 context_->initial_metadata_flags());
589 if (!context_->initial_metadata_corked_) {
595 ClientContext* context_;
612 template <
class W,
class R>
636 virtual void Finish(
const W& msg,
const Status& status,
void* tag) = 0;
662 template <
class W,
class R>
666 : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
678 ctx_->initial_metadata_flags());
682 ctx_->sent_initial_metadata_ =
true;
686 void Read(R* msg,
void* tag)
override {
702 if (!ctx_->sent_initial_metadata_) {
704 ctx_->initial_metadata_flags());
708 ctx_->sent_initial_metadata_ =
true;
729 if (!ctx_->sent_initial_metadata_) {
731 ctx_->initial_metadata_flags());
735 ctx_->sent_initial_metadata_ =
true;
778 virtual void Finish(
const Status& status,
void* tag) = 0;
792 const Status& status,
void* tag) = 0;
801 : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
815 ctx_->initial_metadata_flags());
819 ctx_->sent_initial_metadata_ =
true;
823 void Write(
const W& msg,
void* tag)
override {
825 EnsureInitialMetadataSent(&write_ops_);
837 EnsureInitialMetadataSent(&write_ops_);
851 void* tag)
override {
853 EnsureInitialMetadataSent(&write_ops_);
870 EnsureInitialMetadataSent(&finish_ops_);
879 void EnsureInitialMetadataSent(T* ops) {
880 if (!ctx_->sent_initial_metadata_) {
881 ops->SendInitialMetadata(ctx_->initial_metadata_,
882 ctx_->initial_metadata_flags());
886 ctx_->sent_initial_metadata_ =
true;
904 template <
class W,
class R>
929 virtual void Finish(
const Status& status,
void* tag) = 0;
943 const Status& status,
void* tag) = 0;
950 template <
class W,
class R>
955 : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
969 ctx_->initial_metadata_flags());
973 ctx_->sent_initial_metadata_ =
true;
977 void Read(R* msg,
void* tag)
override {
983 void Write(
const W& msg,
void* tag)
override {
985 EnsureInitialMetadataSent(&write_ops_);
996 EnsureInitialMetadataSent(&write_ops_);
1010 void* tag)
override {
1012 EnsureInitialMetadataSent(&write_ops_);
1029 EnsureInitialMetadataSent(&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());
1048 ctx_->sent_initial_metadata_ =
true;
1053 ServerContext* ctx_;
1068 #endif // GRPCXX_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
grpc_compression_level compression_level() const
Return the compression algorithm to be used by the server call.
Definition: server_context.h:171
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
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:221
void ClientSendClose()
Definition: call.h:467
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
void AllowNoMessage()
Definition: call.h:423
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
virtual void WriteAndFinish(const W &msg, WriteOptions options, const Status &status, void *tag)=0
Request the writing of msg and coalesce it with trailing metadata which contains status, using WriteOptions options with identifying tag tag.
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
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:135
virtual void WritesDone(void *tag)=0
Signal the client is done with the writes (half-close the client stream).
Primary implementaiton of CallOpSetInterface.
Definition: call.h:627
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
void ClientRecvStatus(ClientContext *context, Status *status)
Definition: call.h:563
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: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
virtual void Read(R *msg, void *tag)=0
Read a message of type R into msg.
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
Status SendMessage(const M &message, WriteOptions options) GRPC_MUST_USE_RESULT
Send message using options for the write.
Definition: call.h:317
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
void RecvMessage(R *message)
Definition: call.h:415
virtual void Finish(const Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain status code.
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
virtual void FinishWithError(const Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain non-OK status code.
Server-side interface for asynchronous bi-directional streaming.
Definition: async_stream.h:905
Definition: byte_buffer.h:37
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
grpc_call * call() const
Definition: call.h:703
void ServerSendStatus(const std::multimap< grpc::string, grpc::string > &trailing_metadata, const Status &status)
Definition: call.h:487
An interface that can be fed a sequence of messages of type W.
Definition: async_stream.h:106
void RecvMessage(R *message)
Definition: call.h:345
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:212
void set_output_tag(void *return_tag)
Definition: call.h:660
virtual ~ClientAsyncStreamingInterface()
Definition: async_stream.h:37
bool ok() const
Is the status OK?
Definition: status.h:64
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:30
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
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:699
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
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:186
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
virtual void WriteAndFinish(const W &msg, WriteOptions options, const Status &status, void *tag)=0
Request the writing of msg and coalesce it with trailing metadata which contains status, using WriteOptions options with identifying tag tag.
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
virtual void Finish(const Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain status code.
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
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
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:683
ServerAsyncReader(ServerContext *ctx)
Definition: async_stream.h:665
virtual void Finish(const W &msg, const Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain status code and also send out msg response ...
Common interface for client side asynchronous writing.
Definition: async_stream.h:288