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_);
209 if (!context_->initial_metadata_received_) {
210 ops.RecvInitialMetadata(context_);
214 return cq_.Pluck(&ops) && ops.got_message;
225 ops.ClientRecvStatus(context_, &status);
242 const ::grpc::internal::RpcMethod& method,
248 call_(channel->CreateCall(method, context, &cq_)) {
253 ops.SendInitialMetadata(&context->send_initial_metadata_,
254 context->initial_metadata_flags());
257 ops.ClientSendClose();
283 const ::grpc::internal::RpcMethod& method,
308 ops.RecvInitialMetadata(context_);
328 ops.ClientSendClose();
330 if (context_->initial_metadata_corked_) {
331 ops.SendInitialMetadata(&context_->send_initial_metadata_,
332 context_->initial_metadata_flags());
333 context_->set_initial_metadata_corked(
false);
335 if (!ops.SendMessagePtr(&msg, options).ok()) {
340 return cq_.Pluck(&ops);
345 ops.ClientSendClose();
347 return cq_.Pluck(&ops);
358 if (!context_->initial_metadata_received_) {
359 finish_ops_.RecvInitialMetadata(context_);
361 finish_ops_.ClientRecvStatus(context_, &status);
377 const ::grpc::internal::RpcMethod& method,
383 call_(channel->CreateCall(method, context, &cq_)) {
384 finish_ops_.RecvMessage(response);
385 finish_ops_.AllowNoMessage();
387 if (!context_->initial_metadata_corked_) {
390 ops.SendInitialMetadata(&context->send_initial_metadata_,
391 context->initial_metadata_flags());
409 template <
class W,
class R>
430 template <
class W,
class R>
435 const ::grpc::internal::RpcMethod& method,
446 template <
class W,
class R>
460 ops.RecvInitialMetadata(context_);
478 if (!context_->initial_metadata_received_) {
479 ops.RecvInitialMetadata(context_);
481 ops.RecvMessage(msg);
483 return cq_.Pluck(&ops) && ops.got_message;
500 ops.ClientSendClose();
502 if (context_->initial_metadata_corked_) {
503 ops.SendInitialMetadata(&context_->send_initial_metadata_,
504 context_->initial_metadata_flags());
505 context_->set_initial_metadata_corked(
false);
507 if (!ops.SendMessagePtr(&msg, options).ok()) {
512 return cq_.Pluck(&ops);
517 ops.ClientSendClose();
519 return cq_.Pluck(&ops);
531 if (!context_->initial_metadata_received_) {
532 ops.RecvInitialMetadata(context_);
535 ops.ClientRecvStatus(context_, &status);
552 const ::grpc::internal::RpcMethod& method,
558 call_(channel->CreateCall(method, context, &cq_)) {
559 if (!context_->initial_metadata_corked_) {
562 ops.SendInitialMetadata(&context->send_initial_metadata_,
563 context->initial_metadata_flags());
589 ops.SendInitialMetadata(&ctx_->initial_metadata_,
590 ctx_->initial_metadata_flags());
594 ctx_->sent_initial_metadata_ =
true;
596 call_->
cq()->Pluck(&ops);
606 ops.RecvMessage(msg);
608 return call_->
cq()->Pluck(&ops) && ops.got_message;
615 template <
class ServiceType,
class RequestType,
class ResponseType>
619 : call_(call), ctx_(ctx) {}
642 ops.SendInitialMetadata(&ctx_->initial_metadata_,
643 ctx_->initial_metadata_flags());
647 ctx_->sent_initial_metadata_ =
true;
649 call_->
cq()->Pluck(&ops);
663 if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) {
666 if (!ctx_->sent_initial_metadata_) {
667 ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
668 ctx_->initial_metadata_flags());
672 ctx_->sent_initial_metadata_ =
true;
679 ctx_->has_pending_ops_ =
true;
682 ctx_->has_pending_ops_ =
false;
683 return call_->
cq()->Pluck(&ctx_->pending_ops_);
690 template <
class ServiceType,
class RequestType,
class ResponseType>
694 : call_(call), ctx_(ctx) {}
698 template <
class W,
class R>
705 template <
class W,
class R>
706 class ServerReaderWriterBody final {
710 : call_(call), ctx_(ctx) {}
717 ctx_->initial_metadata_flags());
721 ctx_->sent_initial_metadata_ =
true;
723 call_->
cq()->Pluck(&ops);
733 ops.RecvMessage(msg);
735 return call_->
cq()->Pluck(&ops) && ops.got_message;
742 if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) {
745 if (!ctx_->sent_initial_metadata_) {
746 ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
747 ctx_->initial_metadata_flags());
751 ctx_->sent_initial_metadata_ =
true;
758 ctx_->has_pending_ops_ =
true;
761 ctx_->has_pending_ops_ =
false;
762 return call_->
cq()->Pluck(&ctx_->pending_ops_);
776 template <
class W,
class R>
785 return body_.NextMessageSize(sz);
788 bool Read(R* msg)
override {
return body_.Read(msg); }
797 return body_.Write(msg, options);
807 : body_(call, ctx) {}
818 template <
class RequestType,
class ResponseType>
843 bool Read(RequestType* request)
override {
848 return body_.
Read(request);
859 bool Write(
const ResponseType& response,
861 if (write_done_ || !read_done_) {
865 return body_.
Write(response, options);
877 : body_(call, ctx), read_done_(false), write_done_(false) {}
885 template <
class RequestType,
class ResponseType>
910 bool Read(RequestType* request)
override {
915 return body_.
Read(request);
926 bool Write(
const ResponseType& response,
928 return read_done_ && body_.
Write(response, options);
939 : body_(call, ctx), read_done_(false) {}
944 #endif // GRPCPP_IMPL_CODEGEN_SYNC_STREAM_IMPL_H ::grpc::Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream_impl.h:527
virtual bool NextMessageSize(uint32_t *sz)=0
Get an upper bound on the next message size available for reading on this stream. ...
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream_impl.h:584
bool Write(const W &msg, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:796
virtual ~ReaderInterface()
Definition: sync_stream_impl.h:83
::grpc::Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream_impl.h:222
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
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:146
Synchronous (blocking) client-side API for bi-directional streaming RPCs, where the outgoing message ...
Definition: channel_interface.h:35
::grpc_impl::internal::ClientStreamingHandler< ServiceType, RequestType, ResponseType > ClientStreamingHandler
Definition: method_handler.h:41
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:224
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream_impl.h:637
bool Write(const W &msg, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:492
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
bool WritesDone() override
Half close writing from the client.
Definition: sync_stream_impl.h:515
Synchronous (blocking) client-side API for doing server-streaming RPCs, where the stream of messages ...
Definition: channel_interface.h:31
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
::grpc_impl::CompletionQueue * cq() const
Definition: call.h:73
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the request message size from the client.
Definition: sync_stream_impl.h:829
::grpc_impl::internal::TemplatedBidiStreamingHandler< Streamer, WriteNeeded > TemplatedBidiStreamingHandler
Definition: method_handler.h:50
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream_impl.h:205
Definition: sync_stream_impl.h:160
Primary implementation of CallOpSetInterface.
Definition: call_op_set.h:824
Server-side interface for bi-directional streaming.
Definition: sync_stream_impl.h:699
virtual bool WritesDone()=0
Half close writing from the client.
Definition: sync_stream_impl.h:431
#define GRPC_CQ_CURRENT_VERSION
Definition: grpc_types.h:740
bool Write(const ResponseType &response, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:926
virtual bool Read(R *msg)=0
Block to read a message and parse to msg.
Definition: completion_queue_impl.h:62
bool Read(RequestType *request) override
Read a message of type R into msg.
Definition: sync_stream_impl.h:910
bool Write(const W &msg, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:320
bool Write(const W &msg, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:658
Definition: grpc_types.h:742
A ServerContext or CallbackServerContext allows the code implementing a service handler to: ...
Definition: server_context_impl.h:488
Server-side interface for streaming writes of message of type W.
Definition: sync_stream_impl.h:624
virtual ::grpc::Status Finish()=0
Block waiting until the stream finishes and a final status of the call is available.
::google::protobuf::util::Status Status
Definition: config_protobuf.h:90
::grpc_impl::ClientReaderInterface< R > ClientReaderInterface
Definition: sync_stream.h:53
grpc_compression_level compression_level() const
Return the compression algorithm to be used by the server call.
Definition: server_context_impl.h:209
virtual ~WriterInterface()
Definition: sync_stream_impl.h:106
Synchronous (blocking) server-side API for doing client-streaming RPCs, where the incoming message st...
Definition: completion_queue_impl.h:56
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:784
Events are popped out by calling grpc_completion_queue_pluck() API ONLY.
Definition: grpc_types.h:711
virtual void SendInitialMetadata()=0
Block to send initial metadata to client.
Definition: call_op_set.h:286
::grpc_impl::ClientWriterInterface< W > ClientWriterInterface
Definition: sync_stream.h:59
bool Read(RequestType *request) override
Read a message of type R into msg.
Definition: sync_stream_impl.h:843
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:599
Definition: sync_stream_impl.h:279
bool Read(R *msg) override
Block to read a message and parse to msg.
Definition: sync_stream_impl.h:788
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_impl.h:58
::grpc_impl::ClientReaderWriter< W, R > ClientReaderWriter
Definition: sync_stream.h:69
bool NextMessageSize(uint32_t *sz)
Definition: sync_stream_impl.h:726
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
bool Write(const W &msg, ::grpc::WriteOptions options)
Definition: sync_stream_impl.h:738
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the request message size from the client.
Definition: sync_stream_impl.h:896
::grpc::Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream_impl.h:356
Codegen interface for grpc::Channel.
Definition: channel_interface.h:74
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream_impl.h:826
Client-side interface for streaming writes of message type W.
Definition: sync_stream_impl.h:265
The completion queue will have an associated pollset and there is no restriction on the type of file ...
Definition: grpc_types.h:691
static ClientWriter< W > * Create(::grpc::ChannelInterface *channel, const ::grpc::internal::RpcMethod &method, ::grpc_impl::ClientContext *context, R *response)
Definition: sync_stream_impl.h:282
bool Write(const W &msg)
Block to write msg to the stream with default write options.
Definition: sync_stream_impl.h:123
An interface that can be fed a sequence of messages of type W.
Definition: sync_stream_impl.h:104
virtual bool WritesDone()=0
Half close writing from the client.
::grpc_impl::ClientWriter< W > ClientWriter
Definition: sync_stream.h:62
Definition: byte_buffer.h:58
::grpc_impl::internal::ServerStreamingHandler< ServiceType, RequestType, ResponseType > ServerStreamingHandler
Definition: method_handler.h:46
::grpc_impl::ClientReaderWriterInterface< W, R > ClientReaderWriterInterface
Definition: sync_stream.h:66
Per-message write options.
Definition: call_op_set.h:79
bool WritesDone() override
Half close writing from the client.
Definition: sync_stream_impl.h:343
bool Write(const ResponseType &response, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:859
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream_impl.h:893
A class to represent a flow-controlled unary call.
Definition: sync_stream_impl.h:819
A class to represent a flow-controlled server-side streaming call.
Definition: sync_stream_impl.h:886
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream_impl.h:474
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm_impl.h:33
Definition: call_op_set.h:592
bool Read(R *msg) override
Block to read a message and parse to msg.
Definition: sync_stream_impl.h:604
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:465
virtual void WaitForInitialMetadata()=0
Block to wait for initial metadata from server.
void RecvMessage(R *message)
Definition: call_op_set.h:429
static ClientReaderWriter< W, R > * Create(::grpc::ChannelInterface *channel, const ::grpc::internal::RpcMethod &method, ::grpc_impl::ClientContext *context)
Definition: sync_stream_impl.h:433
int max_receive_message_size() const
Definition: call.h:75
virtual ~ServerStreamingInterface()
Definition: sync_stream_impl.h:68
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue_impl.h:100
void SendInitialMetadata()
Definition: sync_stream_impl.h:712
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
void WaitForInitialMetadata() override
Block waiting to read initial metadata from the server.
Definition: sync_stream_impl.h:455
A ClientContext allows the person implementing a service client to:
Definition: client_context_impl.h:184
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:216
Did it work? If it didn't, why?
Definition: status.h:31
Common interface for all synchronous client side streaming.
Definition: sync_stream_impl.h:34
Client-side interface for bi-directional streaming with client-to-server stream messages of type W an...
Definition: sync_stream_impl.h:410
Definition: call_op_set.h:514
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:68
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
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream_impl.h:782
virtual bool Write(const W &msg, ::grpc::WriteOptions options)=0
Block to write msg to the stream with WriteOptions options.
Definition: call_op_set.h:742
Synchronous (blocking) client-side API for doing client-streaming RPCs, where the outgoing message st...
Definition: channel_interface.h:33
Synchronous (blocking) server-side API for a bidirectional streaming call, where the incoming message...
Definition: sync_stream_impl.h:777
Client-side interface for streaming reads of message of type R.
Definition: sync_stream_impl.h:148
bool Read(R *msg)
Definition: sync_stream_impl.h:731
ServerReaderWriterBody(grpc::internal::Call *call, ::grpc_impl::ServerContext *ctx)
Definition: sync_stream_impl.h:708
An interface that yields a sequence of messages of type R.
Definition: sync_stream_impl.h:81
virtual ~ClientStreamingInterface()
Definition: sync_stream_impl.h:36
void WaitForInitialMetadata() override
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream_impl.h:185
Common interface for all synchronous server side streaming.
Definition: sync_stream_impl.h:66
void WaitForInitialMetadata()
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream_impl.h:303
::grpc_impl::ClientReader< R > ClientReader
Definition: sync_stream.h:56
Server-side interface for streaming reads of message of type R.
Definition: sync_stream_impl.h:572
virtual void WaitForInitialMetadata()=0
Block to wait for initial metadata from server.
Straightforward wrapping of the C call object.
Definition: call.h:38