19 #ifndef GRPCXX_IMPL_CODEGEN_SYNC_STREAM_H
20 #define GRPCXX_IMPL_CODEGEN_SYNC_STREAM_H
99 virtual bool Read(R* msg) = 0;
172 call_(channel->CreateCall(method, context, &cq_)) {
176 ops.SendInitialMetadata(context->send_initial_metadata_,
177 context->initial_metadata_flags());
180 ops.ClientSendClose();
196 ops.RecvInitialMetadata(context_);
213 if (!context_->initial_metadata_received_) {
214 ops.RecvInitialMetadata(context_);
216 ops.RecvMessage(msg);
218 return cq_.Pluck(&ops) && ops.got_message;
229 ops.ClientRecvStatus(context_, &status);
273 call_(channel->CreateCall(method, context, &cq_)) {
274 finish_ops_.RecvMessage(response);
275 finish_ops_.AllowNoMessage();
277 if (!context_->initial_metadata_corked_) {
279 ops.SendInitialMetadata(context->send_initial_metadata_,
280 context->initial_metadata_flags());
296 ops.RecvInitialMetadata(context_);
309 CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
315 ops.ClientSendClose();
317 if (context_->initial_metadata_corked_) {
318 ops.SendInitialMetadata(context_->send_initial_metadata_,
319 context_->initial_metadata_flags());
322 if (!ops.SendMessage(msg, options).ok()) {
327 return cq_.Pluck(&ops);
332 ops.ClientSendClose();
334 return cq_.Pluck(&ops);
345 if (!context_->initial_metadata_received_) {
346 finish_ops_.RecvInitialMetadata(context_);
348 finish_ops_.ClientRecvStatus(context_, &status);
366 template <
class W,
class R>
390 template <
class W,
class R>
402 call_(channel->CreateCall(method, context, &cq_)) {
403 if (!context_->initial_metadata_corked_) {
405 ops.SendInitialMetadata(context->send_initial_metadata_,
406 context->initial_metadata_flags());
422 ops.RecvInitialMetadata(context_);
438 if (!context_->initial_metadata_received_) {
439 ops.RecvInitialMetadata(context_);
441 ops.RecvMessage(msg);
443 return cq_.Pluck(&ops) && ops.got_message;
453 CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
459 ops.ClientSendClose();
461 if (context_->initial_metadata_corked_) {
462 ops.SendInitialMetadata(context_->send_initial_metadata_,
463 context_->initial_metadata_flags());
466 if (!ops.SendMessage(msg, options).ok()) {
471 return cq_.Pluck(&ops);
476 ops.ClientSendClose();
478 return cq_.Pluck(&ops);
488 if (!context_->initial_metadata_received_) {
489 ops.RecvInitialMetadata(context_);
492 ops.ClientRecvStatus(context_, &status);
524 ops.SendInitialMetadata(ctx_->initial_metadata_,
525 ctx_->initial_metadata_flags());
529 ctx_->sent_initial_metadata_ =
true;
531 call_->
cq()->Pluck(&ops);
541 ops.RecvMessage(msg);
543 return call_->
cq()->Pluck(&ops) && ops.got_message;
572 ops.SendInitialMetadata(ctx_->initial_metadata_,
573 ctx_->initial_metadata_flags());
577 ctx_->sent_initial_metadata_ =
true;
579 call_->
cq()->Pluck(&ops);
592 if (!ctx_->pending_ops_.SendMessage(msg, options).ok()) {
595 if (!ctx_->sent_initial_metadata_) {
596 ctx_->pending_ops_.SendInitialMetadata(ctx_->initial_metadata_,
597 ctx_->initial_metadata_flags());
601 ctx_->sent_initial_metadata_ =
true;
608 ctx_->has_pending_ops_ =
true;
611 ctx_->has_pending_ops_ =
false;
612 return call_->
cq()->Pluck(&ctx_->pending_ops_);
621 template <
class W,
class R>
628 template <
class W,
class R>
629 class ServerReaderWriterBody final {
632 : call_(call), ctx_(ctx) {}
638 ops.SendInitialMetadata(ctx_->initial_metadata_,
639 ctx_->initial_metadata_flags());
643 ctx_->sent_initial_metadata_ =
true;
645 call_->
cq()->Pluck(&ops);
655 ops.RecvMessage(msg);
657 return call_->
cq()->Pluck(&ops) && ops.got_message;
664 if (!ctx_->pending_ops_.SendMessage(msg, options).ok()) {
667 if (!ctx_->sent_initial_metadata_) {
668 ctx_->pending_ops_.SendInitialMetadata(ctx_->initial_metadata_,
669 ctx_->initial_metadata_flags());
673 ctx_->sent_initial_metadata_ =
true;
680 ctx_->has_pending_ops_ =
true;
683 ctx_->has_pending_ops_ =
false;
684 return call_->
cq()->Pluck(&ctx_->pending_ops_);
697 template <
class W,
class R>
708 return body_.NextMessageSize(sz);
711 bool Read(R* msg)
override {
return body_.Read(msg); }
720 return body_.Write(msg, options);
735 template <
class RequestType,
class ResponseType>
740 : body_(call, ctx), read_done_(false), write_done_(false) {}
763 bool Read(RequestType* request)
override {
768 return body_.
Read(request);
780 if (write_done_ || !read_done_) {
784 return body_.
Write(response, options);
798 template <
class RequestType,
class ResponseType>
803 : body_(call, ctx), read_done_(false) {}
826 bool Read(RequestType* request)
override {
831 return body_.
Read(request);
843 return read_done_ && body_.
Write(response, options);
853 #endif // GRPCXX_IMPL_CODEGEN_SYNC_STREAM_H
Synchronous (blocking) client-side API for doing server-streaming RPCs, where the stream of messages ...
Definition: channel_interface.h:34
Client-side interface for streaming writes of message type W.
Definition: sync_stream.h:243
grpc_compression_level compression_level() const
Return the compression algorithm to be used by the server call.
Definition: server_context.h:170
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:121
bool Read(R *msg) override
Block to read a message and parse to msg.
Definition: sync_stream.h:711
virtual void WaitForInitialMetadata()=0
Block to wait for initial metadata from server.
Common interface for all synchronous server side streaming.
Definition: sync_stream.h:66
bool Write(const W &msg, WriteOptions options)
Definition: sync_stream.h:660
Server-side interface for bi-directional streaming.
Definition: sync_stream.h:622
A class to represent a flow-controlled server-side streaming call.
Definition: sync_stream.h:799
ServerReaderWriterBody(Call *call, ServerContext *ctx)
Definition: sync_stream.h:631
bool NextMessageSize(uint32_t *sz)
Definition: sync_stream.h:648
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream. ...
Definition: sync_stream.h:427
Client-side interface for streaming reads of message of type R.
Definition: sync_stream.h:146
Definition: completion_queue.h:58
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:160
virtual ~ServerStreamingInterface()
Definition: sync_stream.h:68
An interface that yields a sequence of messages of type R.
Definition: sync_stream.h:81
bool Write(const ResponseType &response, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:779
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:126
A class to represent a flow-controlled unary call.
Definition: sync_stream.h:736
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream.h:211
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream.h:520
virtual ~ReaderInterface()
Definition: sync_stream.h:83
void set_initial_metadata_corked(bool corked)
Flag whether the initial metadata should be corked.
Definition: client_context.h:300
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream.h:809
bool Read(R *msg)
Definition: sync_stream.h:653
#define GRPC_CQ_CURRENT_VERSION
Definition: grpc_types.h:600
Server-side interface for streaming reads of message of type R.
Definition: sync_stream.h:506
Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream.h:226
bool Read(R *msg) override
Block to read a message and parse to msg.
Definition: sync_stream.h:539
bool Write(const ResponseType &response, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:842
bool WritesDone() override
Half close writing from the client.
Definition: sync_stream.h:330
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream.h:436
Definition: grpc_types.h:601
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:153
Synchronous (blocking) server-side API for doing client-streaming RPCs, where the incoming message st...
Definition: completion_queue.h:53
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream. ...
Definition: sync_stream.h:201
bool Write(const W &msg, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:452
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the request message size from the client.
Definition: sync_stream.h:812
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream.h:705
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream. ...
Definition: sync_stream.h:707
void SendInitialMetadata()
Definition: sync_stream.h:634
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream.h:568
ServerReader(Call *call, ServerContext *ctx)
Definition: sync_stream.h:515
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the request message size from the client.
Definition: sync_stream.h:749
bool Read(RequestType *request) override
Read a message of type R into msg.
Definition: sync_stream.h:763
bool Write(const W &msg, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:719
Events are popped out by calling grpc_completion_queue_pluck() API ONLY.
Definition: grpc_types.h:597
virtual ~ClientStreamingInterface()
Definition: sync_stream.h:36
Server-side interface for streaming writes of message of type W.
Definition: sync_stream.h:553
virtual bool NextMessageSize(uint32_t *sz)=0
Get an upper bound on the next message size available for reading on this stream. ...
ClientReader(ChannelInterface *channel, const RpcMethod &method, ClientContext *context, const W &request)
Block to create a stream and write the initial metadata and request out.
Definition: sync_stream.h:166
CompletionQueue * cq() const
Definition: call.h:668
int max_receive_message_size() const
Definition: call.h:670
bool Write(const W &msg, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:588
Straightforward wrapping of the C call object.
Definition: call.h:647
virtual bool WritesDone()=0
Half close writing from the client.
Codegen interface for grpc::Channel.
Definition: channel_interface.h:49
virtual bool Write(const W &msg, WriteOptions options)=0
Block to write msg to the stream with WriteOptions options.
virtual void SendInitialMetadata()=0
Block to send initial metadata to client.
The completion queue will have an associated pollset and there is no restriction on the type of file ...
Definition: grpc_types.h:577
Primary implementaiton of CallOpSetInterface.
Definition: call.h:591
Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream.h:343
A ServerContext allows the person implementing a service handler to:
Definition: server_context.h:95
ServerSplitStreamer(Call *call, ServerContext *ctx)
Definition: sync_stream.h:802
Per-message write options.
Definition: call.h:81
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream.h:746
ClientReaderWriter(ChannelInterface *channel, const RpcMethod &method, ClientContext *context)
Block to create a stream and write the initial metadata and request out.
Definition: sync_stream.h:396
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream. ...
Definition: sync_stream.h:534
virtual void WaitForInitialMetadata()=0
Block to wait for initial metadata from server.
virtual bool WritesDone()=0
Half close writing from the client.
bool Write(const W &msg)
Block to write msg to the stream with default write options.
Definition: sync_stream.h:123
Synchronous (blocking) server-side API for doing for doing a server-streaming RPCs, where the outgoing message stream coming from the server has messages of type W.
Definition: completion_queue.h:55
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:86
ServerUnaryStreamer(Call *call, ServerContext *ctx)
Definition: sync_stream.h:739
bool WritesDone() override
Half close writing from the client.
Definition: sync_stream.h:474
Descriptor of an RPC method.
Definition: rpc_method.h:29
Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream.h:486
virtual Status Finish()=0
Block waiting until the stream finishes and a final status of the call is available.
void WaitForInitialMetadata() override
Block waiting to read initial metadata from the server.
Definition: sync_stream.h:418
ServerReaderWriter(Call *call, ServerContext *ctx)
Definition: sync_stream.h:700
Synchronous (blocking) server-side API for a bidirectional streaming call, where the incoming message...
Definition: sync_stream.h:698
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:663
An interface that can be fed a sequence of messages of type W.
Definition: sync_stream.h:104
Client-side interface for bi-directional streaming with client-to-server stream messages of type W an...
Definition: sync_stream.h:367
Did it work? If it didn't, why?
Definition: status.h:30
void WaitForInitialMetadata() override
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream.h:192
virtual bool Read(R *msg)=0
Block to read a message and parse to msg.
Common interface for all synchronous client side streaming.
Definition: sync_stream.h:34
ServerWriter(Call *call, ServerContext *ctx)
Definition: sync_stream.h:562
bool Read(RequestType *request) override
Read a message of type R into msg.
Definition: sync_stream.h:826
void WriteLast(const W &msg, WriteOptions options)
Write msg and coalesce it with the writing of trailing metadata, using WriteOptions options...
Definition: sync_stream.h:139
void WaitForInitialMetadata()
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream.h:292
Synchronous (blocking) client-side API for bi-directional streaming RPCs, where the outgoing message ...
Definition: channel_interface.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.h:185
Synchronous (blocking) client-side API for doing client-streaming RPCs, where the outgoing message st...
Definition: channel_interface.h:36
ClientWriter(ChannelInterface *channel, const RpcMethod &method, ClientContext *context, R *response)
Block to create a stream (i.e.
Definition: sync_stream.h:267
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:176
virtual ~WriterInterface()
Definition: sync_stream.h:106
bool Write(const W &msg, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:308