Go to the documentation of this file.
18 #ifndef GRPCPP_IMPL_CODEGEN_SYNC_STREAM_IMPL_H
19 #define GRPCPP_IMPL_CODEGEN_SYNC_STREAM_IMPL_H
99 virtual bool Read(R* msg) = 0;
164 const ::grpc::internal::RpcMethod& method,
190 ops.RecvInitialMetadata(context_);
197 *sz = (result > 0) ? result : UINT32_MAX;
210 if (!context_->initial_metadata_received_) {
211 ops.RecvInitialMetadata(context_);
215 return cq_.Pluck(&ops) && ops.got_message;
226 ops.ClientRecvStatus(context_, &status);
243 const ::grpc::internal::RpcMethod& method,
249 call_(channel->CreateCall(method, context, &cq_)) {
254 ops.SendInitialMetadata(&context->send_initial_metadata_,
255 context->initial_metadata_flags());
258 ops.ClientSendClose();
284 const ::grpc::internal::RpcMethod& method,
309 ops.RecvInitialMetadata(context_);
329 ops.ClientSendClose();
331 if (context_->initial_metadata_corked_) {
332 ops.SendInitialMetadata(&context_->send_initial_metadata_,
333 context_->initial_metadata_flags());
334 context_->set_initial_metadata_corked(
false);
336 if (!ops.SendMessagePtr(&msg, options).ok()) {
341 return cq_.Pluck(&ops);
346 ops.ClientSendClose();
348 return cq_.Pluck(&ops);
359 if (!context_->initial_metadata_received_) {
360 finish_ops_.RecvInitialMetadata(context_);
362 finish_ops_.ClientRecvStatus(context_, &status);
378 const ::grpc::internal::RpcMethod& method,
384 call_(channel->CreateCall(method, context, &cq_)) {
385 finish_ops_.RecvMessage(response);
386 finish_ops_.AllowNoMessage();
388 if (!context_->initial_metadata_corked_) {
391 ops.SendInitialMetadata(&context->send_initial_metadata_,
392 context->initial_metadata_flags());
410 template <
class W,
class R>
431 template <
class W,
class R>
436 const ::grpc::internal::RpcMethod& method,
447 template <
class W,
class R>
461 ops.RecvInitialMetadata(context_);
468 *sz = (result > 0) ? result : UINT32_MAX;
480 if (!context_->initial_metadata_received_) {
481 ops.RecvInitialMetadata(context_);
483 ops.RecvMessage(msg);
485 return cq_.Pluck(&ops) && ops.got_message;
502 ops.ClientSendClose();
504 if (context_->initial_metadata_corked_) {
505 ops.SendInitialMetadata(&context_->send_initial_metadata_,
506 context_->initial_metadata_flags());
507 context_->set_initial_metadata_corked(
false);
509 if (!ops.SendMessagePtr(&msg, options).ok()) {
514 return cq_.Pluck(&ops);
519 ops.ClientSendClose();
521 return cq_.Pluck(&ops);
533 if (!context_->initial_metadata_received_) {
534 ops.RecvInitialMetadata(context_);
537 ops.ClientRecvStatus(context_, &status);
554 const ::grpc::internal::RpcMethod& method,
560 call_(channel->CreateCall(method, context, &cq_)) {
561 if (!context_->initial_metadata_corked_) {
564 ops.SendInitialMetadata(&context->send_initial_metadata_,
565 context->initial_metadata_flags());
591 ops.SendInitialMetadata(&ctx_->initial_metadata_,
592 ctx_->initial_metadata_flags());
596 ctx_->sent_initial_metadata_ =
true;
598 call_->
cq()->Pluck(&ops);
603 *sz = (result > 0) ? result : UINT32_MAX;
609 ops.RecvMessage(msg);
611 return call_->
cq()->Pluck(&ops) && ops.got_message;
618 template <
class ServiceType,
class RequestType,
class ResponseType>
622 : call_(call), ctx_(ctx) {}
645 ops.SendInitialMetadata(&ctx_->initial_metadata_,
646 ctx_->initial_metadata_flags());
650 ctx_->sent_initial_metadata_ =
true;
652 call_->
cq()->Pluck(&ops);
666 if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) {
669 if (!ctx_->sent_initial_metadata_) {
670 ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
671 ctx_->initial_metadata_flags());
675 ctx_->sent_initial_metadata_ =
true;
682 ctx_->has_pending_ops_ =
true;
685 ctx_->has_pending_ops_ =
false;
686 return call_->
cq()->Pluck(&ctx_->pending_ops_);
693 template <
class ServiceType,
class RequestType,
class ResponseType>
697 : call_(call), ctx_(ctx) {}
701 template <
class W,
class R>
708 template <
class W,
class R>
709 class ServerReaderWriterBody final {
713 : call_(call), ctx_(ctx) {}
720 ctx_->initial_metadata_flags());
724 ctx_->sent_initial_metadata_ =
true;
726 call_->
cq()->Pluck(&ops);
731 *sz = (result > 0) ? result : UINT32_MAX;
737 ops.RecvMessage(msg);
739 return call_->
cq()->Pluck(&ops) && ops.got_message;
746 if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) {
749 if (!ctx_->sent_initial_metadata_) {
750 ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
751 ctx_->initial_metadata_flags());
755 ctx_->sent_initial_metadata_ =
true;
762 ctx_->has_pending_ops_ =
true;
765 ctx_->has_pending_ops_ =
false;
766 return call_->
cq()->Pluck(&ctx_->pending_ops_);
780 template <
class W,
class R>
789 return body_.NextMessageSize(sz);
792 bool Read(R* msg)
override {
return body_.Read(msg); }
801 return body_.Write(msg, options);
811 : body_(call, ctx) {}
822 template <
class RequestType,
class ResponseType>
847 bool Read(RequestType* request)
override {
852 return body_.
Read(request);
863 bool Write(
const ResponseType& response,
865 if (write_done_ || !read_done_) {
869 return body_.
Write(response, options);
881 : body_(call, ctx), read_done_(false), write_done_(false) {}
889 template <
class RequestType,
class ResponseType>
914 bool Read(RequestType* request)
override {
919 return body_.
Read(request);
930 bool Write(
const ResponseType& response,
932 return read_done_ && body_.
Write(response, options);
943 : body_(call, ctx), read_done_(false) {}
948 #endif // GRPCPP_IMPL_CODEGEN_SYNC_STREAM_IMPL_H
virtual ~ServerStreamingInterface()
Definition: sync_stream_impl.h:68
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream_impl.h:640
Definition: sync_stream_impl.h:432
Definition: call_op_set.h:617
Definition: sync_stream_impl.h:280
Definition: call_op_set.h:524
bool WritesDone() override
Half close writing from the client.
Definition: sync_stream_impl.h:517
virtual void WaitForInitialMetadata()=0
Block to wait for initial metadata from server.
virtual bool Read(R *msg)=0
Block to read a message and parse to msg.
int max_receive_message_size() const
Definition: call.h:75
::grpc_impl::internal::TemplatedBidiStreamingHandler< Streamer, WriteNeeded > TemplatedBidiStreamingHandler
Definition: method_handler.h:50
Primary implementation of CallOpSetInterface.
Definition: call_op_set.h:849
Definition: call_op_set.h:286
Common interface for all synchronous client side streaming.
Definition: sync_stream_impl.h:34
grpc_compression_level compression_level() const
Return the compression algorithm to be used by the server call.
Definition: server_context_impl.h:215
bool Write(const W &msg, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:800
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
void SendInitialMetadata()
Definition: sync_stream_impl.h:715
Common interface for all synchronous server side streaming.
Definition: sync_stream_impl.h:66
::grpc::Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream_impl.h:529
Server-side interface for bi-directional streaming.
Definition: sync_stream_impl.h:702
Client-side interface for streaming reads of message of type R.
Definition: sync_stream_impl.h:148
void WriteLast(const W &msg, ::grpc::WriteOptions options)
Write msg and coalesce it with the writing of trailing metadata, using WriteOptions options.
Definition: sync_stream_impl.h:139
A class to represent a flow-controlled unary call.
Definition: sync_stream_impl.h:823
::grpc_impl::ClientWriter< W > ClientWriter
Definition: sync_stream.h:62
bool NextMessageSize(uint32_t *sz)
Definition: sync_stream_impl.h:729
bool Write(const W &msg, ::grpc::WriteOptions options)
Definition: sync_stream_impl.h:742
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream.
Definition: sync_stream_impl.h:195
Straightforward wrapping of the C call object.
Definition: call.h:38
virtual bool Write(const W &msg, ::grpc::WriteOptions options)=0
Block to write msg to the stream with WriteOptions options.
virtual ~ClientStreamingInterface()
Definition: sync_stream_impl.h:36
An interface that can be fed a sequence of messages of type W.
Definition: sync_stream_impl.h:104
Synchronous (blocking) server-side API for a bidirectional streaming call, where the incoming message...
Definition: sync_stream_impl.h:781
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream_impl.h:586
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
virtual void SendInitialMetadata()=0
Block to send initial metadata to client.
bool Write(const ResponseType &response, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:930
Synchronous (blocking) client-side API for doing server-streaming RPCs, where the stream of messages ...
Definition: channel_interface.h:31
ServerReaderWriterBody(grpc::internal::Call *call, ::grpc_impl::ServerContext *ctx)
Definition: sync_stream_impl.h:711
virtual bool NextMessageSize(uint32_t *sz)=0
Get an upper bound on the next message size available for reading on this stream.
Synchronous (blocking) client-side API for bi-directional streaming RPCs, where the outgoing message ...
Definition: channel_interface.h:35
bool Read(RequestType *request) override
Read a message of type R into msg.
Definition: sync_stream_impl.h:914
::grpc::Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream_impl.h:357
Did it work? If it didn't, why?
Definition: status.h:31
A ServerContext or CallbackServerContext allows the code implementing a service handler to:
Definition: server_context_impl.h:510
bool Read(R *msg) override
Block to read a message and parse to msg.
Definition: sync_stream_impl.h:792
::grpc_impl::internal::ServerStreamingHandler< ServiceType, RequestType, ResponseType > ServerStreamingHandler
Definition: method_handler.h:46
The completion queue will have an associated pollset and there is no restriction on the type of file ...
Definition: grpc_types.h:708
void WaitForInitialMetadata()
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream_impl.h:304
bool Write(const W &msg, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:661
virtual bool WritesDone()=0
Half close writing from the client.
::grpc::Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream_impl.h:223
bool Write(const ResponseType &response, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:863
bool Write(const W &msg)
Block to write msg to the stream with default write options.
Definition: sync_stream_impl.h:123
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream_impl.h:830
Definition: sync_stream_impl.h:160
virtual ::grpc::Status Finish()=0
Block waiting until the stream finishes and a final status of the call is available.
bool Write(const W &msg, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:321
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream_impl.h:897
void WaitForInitialMetadata() override
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream_impl.h:185
Synchronous (blocking) server-side API for doing for doing a server-streaming RPCs,...
Definition: completion_queue_impl.h:61
void set_compression_level(grpc_compression_level level)
Set level to be the compression level used for the server call.
Definition: server_context_impl.h:222
Codegen interface for grpc::Channel.
Definition: channel_interface.h:74
virtual ~ReaderInterface()
Definition: sync_stream_impl.h:83
A class to represent a flow-controlled server-side streaming call.
Definition: sync_stream_impl.h:890
Client-side interface for streaming writes of message type W.
Definition: sync_stream_impl.h:266
Events are popped out by calling grpc_completion_queue_pluck() API ONLY.
Definition: grpc_types.h:728
bool WritesDone() override
Half close writing from the client.
Definition: sync_stream_impl.h:344
bool Read(R *msg)
Definition: sync_stream_impl.h:735
::grpc_impl::ClientWriterInterface< W > ClientWriterInterface
Definition: sync_stream.h:59
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream.
Definition: sync_stream_impl.h:466
Definition: grpc_types.h:759
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream.
Definition: sync_stream_impl.h:788
::google::protobuf::util::Status Status
Definition: config_protobuf.h:90
Server-side interface for streaming writes of message of type W.
Definition: sync_stream_impl.h:627
Synchronous (blocking) client-side API for doing client-streaming RPCs, where the outgoing message st...
Definition: channel_interface.h:33
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream_impl.h:206
::grpc_impl::ClientReaderInterface< R > ClientReaderInterface
Definition: sync_stream.h:53
static ClientReader< R > * Create(::grpc::ChannelInterface *channel, const ::grpc::internal::RpcMethod &method, ::grpc_impl::ClientContext *context, const W &request)
Definition: sync_stream_impl.h:163
Per-message write options.
Definition: call_op_set.h:79
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream.
Definition: sync_stream_impl.h:601
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream_impl.h:786
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the request message size from the client.
Definition: sync_stream_impl.h:833
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue_impl.h:103
An interface that yields a sequence of messages of type R.
Definition: sync_stream_impl.h:81
Definition: completion_queue_impl.h:65
#define GRPC_CQ_CURRENT_VERSION
Definition: grpc_types.h:757
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:68
static ClientWriter< W > * Create(::grpc::ChannelInterface *channel, const ::grpc::internal::RpcMethod &method, ::grpc_impl::ClientContext *context, R *response)
Definition: sync_stream_impl.h:283
bool Read(R *msg) override
Block to read a message and parse to msg.
Definition: sync_stream_impl.h:607
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
::grpc_impl::ClientReader< R > ClientReader
Definition: sync_stream.h:56
::grpc_impl::ClientReaderWriterInterface< W, R > ClientReaderWriterInterface
Definition: sync_stream.h:66
Synchronous (blocking) server-side API for doing client-streaming RPCs, where the incoming message st...
Definition: completion_queue_impl.h:59
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm_impl.h:33
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream_impl.h:476
::grpc_impl::ClientReaderWriter< W, R > ClientReaderWriter
Definition: sync_stream.h:69
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:146
::grpc_impl::CompletionQueue * cq() const
Definition: call.h:73
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
Definition: byte_buffer.h:58
virtual void WaitForInitialMetadata()=0
Block to wait for initial metadata from server.
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the request message size from the client.
Definition: sync_stream_impl.h:900
static ClientReaderWriter< W, R > * Create(::grpc::ChannelInterface *channel, const ::grpc::internal::RpcMethod &method, ::grpc_impl::ClientContext *context)
Definition: sync_stream_impl.h:434
Client-side interface for bi-directional streaming with client-to-server stream messages of type W an...
Definition: sync_stream_impl.h:411
Server-side interface for streaming reads of message of type R.
Definition: sync_stream_impl.h:574
virtual ~WriterInterface()
Definition: sync_stream_impl.h:106
::grpc_impl::internal::ClientStreamingHandler< ServiceType, RequestType, ResponseType > ClientStreamingHandler
Definition: method_handler.h:41
bool Write(const W &msg, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:494
void WaitForInitialMetadata() override
Block waiting to read initial metadata from the server.
Definition: sync_stream_impl.h:456
void RecvMessage(R *message)
Definition: call_op_set.h:424
virtual bool WritesDone()=0
Half close writing from the client.
bool Read(RequestType *request) override
Read a message of type R into msg.
Definition: sync_stream_impl.h:847