GRPC C++  1.13.0-dev
async_stream.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H
20 #define GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H
21 
28 
29 namespace grpc {
30 
31 class CompletionQueue;
32 
33 namespace internal {
36  public:
38 
42  virtual void StartCall(void* tag) = 0;
43 
50  virtual void ReadInitialMetadata(void* tag) = 0;
51 
79  virtual void Finish(Status* status, void* tag) = 0;
80 };
81 
83 template <class R>
85  public:
86  virtual ~AsyncReaderInterface() {}
87 
101  virtual void Read(R* msg, void* tag) = 0;
102 };
103 
105 template <class W>
107  public:
109 
119  virtual void Write(const W& msg, void* tag) = 0;
120 
133  virtual void Write(const W& msg, WriteOptions options, void* tag) = 0;
134 
150  void WriteLast(const W& msg, WriteOptions options, void* tag) {
151  Write(msg, options.set_last_message(), tag);
152  }
153 };
154 
155 } // namespace internal
156 
157 template <class R>
160  public internal::AsyncReaderInterface<R> {};
161 
162 namespace internal {
163 template <class R>
165  public:
173  template <class W>
175  CompletionQueue* cq,
176  const ::grpc::internal::RpcMethod& method,
177  ClientContext* context, const W& request,
178  bool start, void* tag) {
179  ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
181  call.call(), sizeof(ClientAsyncReader<R>)))
182  ClientAsyncReader<R>(call, context, request, start, tag);
183  }
184 };
185 } // namespace internal
186 
190 template <class R>
192  public:
193  // always allocated against a call arena, no memory free required
194  static void operator delete(void* ptr, std::size_t size) {
195  assert(size == sizeof(ClientAsyncReader));
196  }
197 
198  void StartCall(void* tag) override {
199  assert(!started_);
200  started_ = true;
201  StartCallInternal(tag);
202  }
203 
212  void ReadInitialMetadata(void* tag) override {
213  assert(started_);
214  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
215 
216  meta_ops_.set_output_tag(tag);
217  meta_ops_.RecvInitialMetadata(context_);
218  call_.PerformOps(&meta_ops_);
219  }
220 
221  void Read(R* msg, void* tag) override {
222  assert(started_);
223  read_ops_.set_output_tag(tag);
224  if (!context_->initial_metadata_received_) {
225  read_ops_.RecvInitialMetadata(context_);
226  }
227  read_ops_.RecvMessage(msg);
228  call_.PerformOps(&read_ops_);
229  }
230 
236  void Finish(Status* status, void* tag) override {
237  assert(started_);
238  finish_ops_.set_output_tag(tag);
239  if (!context_->initial_metadata_received_) {
240  finish_ops_.RecvInitialMetadata(context_);
241  }
242  finish_ops_.ClientRecvStatus(context_, status);
243  call_.PerformOps(&finish_ops_);
244  }
245 
246  private:
248  template <class W>
250  const W& request, bool start, void* tag)
251  : context_(context), call_(call), started_(start) {
252  // TODO(ctiller): don't assert
253  GPR_CODEGEN_ASSERT(init_ops_.SendMessage(request).ok());
254  init_ops_.ClientSendClose();
255  if (start) {
256  StartCallInternal(tag);
257  } else {
258  assert(tag == nullptr);
259  }
260  }
261 
262  void StartCallInternal(void* tag) {
263  init_ops_.SendInitialMetadata(context_->send_initial_metadata_,
264  context_->initial_metadata_flags());
265  init_ops_.set_output_tag(tag);
266  call_.PerformOps(&init_ops_);
267  }
268 
269  ClientContext* context_;
271  bool started_;
275  init_ops_;
277  meta_ops_;
280  read_ops_;
281  ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
283  finish_ops_;
284 };
285 
287 template <class W>
291  public:
296  virtual void WritesDone(void* tag) = 0;
297 };
298 
299 namespace internal {
300 template <class W>
302  public:
314  template <class R>
316  CompletionQueue* cq,
317  const ::grpc::internal::RpcMethod& method,
318  ClientContext* context, R* response,
319  bool start, void* tag) {
320  ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
322  call.call(), sizeof(ClientAsyncWriter<W>)))
323  ClientAsyncWriter<W>(call, context, response, start, tag);
324  }
325 };
326 } // namespace internal
327 
331 template <class W>
333  public:
334  // always allocated against a call arena, no memory free required
335  static void operator delete(void* ptr, std::size_t size) {
336  assert(size == sizeof(ClientAsyncWriter));
337  }
338 
339  void StartCall(void* tag) override {
340  assert(!started_);
341  started_ = true;
342  StartCallInternal(tag);
343  }
344 
352  void ReadInitialMetadata(void* tag) override {
353  assert(started_);
354  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
355 
356  meta_ops_.set_output_tag(tag);
357  meta_ops_.RecvInitialMetadata(context_);
358  call_.PerformOps(&meta_ops_);
359  }
360 
361  void Write(const W& msg, void* tag) override {
362  assert(started_);
363  write_ops_.set_output_tag(tag);
364  // TODO(ctiller): don't assert
365  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
366  call_.PerformOps(&write_ops_);
367  }
368 
369  void Write(const W& msg, WriteOptions options, void* tag) override {
370  assert(started_);
371  write_ops_.set_output_tag(tag);
372  if (options.is_last_message()) {
373  options.set_buffer_hint();
374  write_ops_.ClientSendClose();
375  }
376  // TODO(ctiller): don't assert
377  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
378  call_.PerformOps(&write_ops_);
379  }
380 
381  void WritesDone(void* tag) override {
382  assert(started_);
383  write_ops_.set_output_tag(tag);
384  write_ops_.ClientSendClose();
385  call_.PerformOps(&write_ops_);
386  }
387 
395  void Finish(Status* status, void* tag) override {
396  assert(started_);
397  finish_ops_.set_output_tag(tag);
398  if (!context_->initial_metadata_received_) {
399  finish_ops_.RecvInitialMetadata(context_);
400  }
401  finish_ops_.ClientRecvStatus(context_, status);
402  call_.PerformOps(&finish_ops_);
403  }
404 
405  private:
407  template <class R>
409  R* response, bool start, void* tag)
410  : context_(context), call_(call), started_(start) {
411  finish_ops_.RecvMessage(response);
412  finish_ops_.AllowNoMessage();
413  if (start) {
414  StartCallInternal(tag);
415  } else {
416  assert(tag == nullptr);
417  }
418  }
419 
420  void StartCallInternal(void* tag) {
421  write_ops_.SendInitialMetadata(context_->send_initial_metadata_,
422  context_->initial_metadata_flags());
423  // if corked bit is set in context, we just keep the initial metadata
424  // buffered up to coalesce with later message send. No op is performed.
425  if (!context_->initial_metadata_corked_) {
426  write_ops_.set_output_tag(tag);
427  call_.PerformOps(&write_ops_);
428  }
429  }
430 
431  ClientContext* context_;
433  bool started_;
435  meta_ops_;
439  write_ops_;
443  finish_ops_;
444 };
445 
449 template <class W, class R>
454  public:
459  virtual void WritesDone(void* tag) = 0;
460 };
461 
462 namespace internal {
463 template <class W, class R>
465  public:
474  ChannelInterface* channel, CompletionQueue* cq,
475  const ::grpc::internal::RpcMethod& method, ClientContext* context,
476  bool start, void* tag) {
477  ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
478 
480  call.call(), sizeof(ClientAsyncReaderWriter<W, R>)))
481  ClientAsyncReaderWriter<W, R>(call, context, start, tag);
482  }
483 };
484 } // namespace internal
485 
490 template <class W, class R>
492  : public ClientAsyncReaderWriterInterface<W, R> {
493  public:
494  // always allocated against a call arena, no memory free required
495  static void operator delete(void* ptr, std::size_t size) {
496  assert(size == sizeof(ClientAsyncReaderWriter));
497  }
498 
499  void StartCall(void* tag) override {
500  assert(!started_);
501  started_ = true;
502  StartCallInternal(tag);
503  }
504 
512  void ReadInitialMetadata(void* tag) override {
513  assert(started_);
514  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
515 
516  meta_ops_.set_output_tag(tag);
517  meta_ops_.RecvInitialMetadata(context_);
518  call_.PerformOps(&meta_ops_);
519  }
520 
521  void Read(R* msg, void* tag) override {
522  assert(started_);
523  read_ops_.set_output_tag(tag);
524  if (!context_->initial_metadata_received_) {
525  read_ops_.RecvInitialMetadata(context_);
526  }
527  read_ops_.RecvMessage(msg);
528  call_.PerformOps(&read_ops_);
529  }
530 
531  void Write(const W& msg, void* tag) override {
532  assert(started_);
533  write_ops_.set_output_tag(tag);
534  // TODO(ctiller): don't assert
535  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
536  call_.PerformOps(&write_ops_);
537  }
538 
539  void Write(const W& msg, WriteOptions options, void* tag) override {
540  assert(started_);
541  write_ops_.set_output_tag(tag);
542  if (options.is_last_message()) {
543  options.set_buffer_hint();
544  write_ops_.ClientSendClose();
545  }
546  // TODO(ctiller): don't assert
547  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
548  call_.PerformOps(&write_ops_);
549  }
550 
551  void WritesDone(void* tag) override {
552  assert(started_);
553  write_ops_.set_output_tag(tag);
554  write_ops_.ClientSendClose();
555  call_.PerformOps(&write_ops_);
556  }
557 
562  void Finish(Status* status, void* tag) override {
563  assert(started_);
564  finish_ops_.set_output_tag(tag);
565  if (!context_->initial_metadata_received_) {
566  finish_ops_.RecvInitialMetadata(context_);
567  }
568  finish_ops_.ClientRecvStatus(context_, status);
569  call_.PerformOps(&finish_ops_);
570  }
571 
572  private:
575  bool start, void* tag)
576  : context_(context), call_(call), started_(start) {
577  if (start) {
578  StartCallInternal(tag);
579  } else {
580  assert(tag == nullptr);
581  }
582  }
583 
584  void StartCallInternal(void* tag) {
585  write_ops_.SendInitialMetadata(context_->send_initial_metadata_,
586  context_->initial_metadata_flags());
587  // if corked bit is set in context, we just keep the initial metadata
588  // buffered up to coalesce with later message send. No op is performed.
589  if (!context_->initial_metadata_corked_) {
590  write_ops_.set_output_tag(tag);
591  call_.PerformOps(&write_ops_);
592  }
593  }
594 
595  ClientContext* context_;
597  bool started_;
599  meta_ops_;
602  read_ops_;
606  write_ops_;
607  ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
609  finish_ops_;
610 };
611 
612 template <class W, class R>
616  public:
636  virtual void Finish(const W& msg, const Status& status, void* tag) = 0;
637 
656  virtual void FinishWithError(const Status& status, void* tag) = 0;
657 };
658 
662 template <class W, class R>
663 class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
664  public:
666  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
667 
673  void SendInitialMetadata(void* tag) override {
674  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
675 
676  meta_ops_.set_output_tag(tag);
677  meta_ops_.SendInitialMetadata(ctx_->initial_metadata_,
678  ctx_->initial_metadata_flags());
679  if (ctx_->compression_level_set()) {
680  meta_ops_.set_compression_level(ctx_->compression_level());
681  }
682  ctx_->sent_initial_metadata_ = true;
683  call_.PerformOps(&meta_ops_);
684  }
685 
686  void Read(R* msg, void* tag) override {
687  read_ops_.set_output_tag(tag);
688  read_ops_.RecvMessage(msg);
689  call_.PerformOps(&read_ops_);
690  }
691 
700  void Finish(const W& msg, const Status& status, void* tag) override {
701  finish_ops_.set_output_tag(tag);
702  if (!ctx_->sent_initial_metadata_) {
703  finish_ops_.SendInitialMetadata(ctx_->initial_metadata_,
704  ctx_->initial_metadata_flags());
705  if (ctx_->compression_level_set()) {
706  finish_ops_.set_compression_level(ctx_->compression_level());
707  }
708  ctx_->sent_initial_metadata_ = true;
709  }
710  // The response is dropped if the status is not OK.
711  if (status.ok()) {
712  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_,
713  finish_ops_.SendMessage(msg));
714  } else {
715  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
716  }
717  call_.PerformOps(&finish_ops_);
718  }
719 
726  void FinishWithError(const Status& status, void* tag) override {
727  GPR_CODEGEN_ASSERT(!status.ok());
728  finish_ops_.set_output_tag(tag);
729  if (!ctx_->sent_initial_metadata_) {
730  finish_ops_.SendInitialMetadata(ctx_->initial_metadata_,
731  ctx_->initial_metadata_flags());
732  if (ctx_->compression_level_set()) {
733  finish_ops_.set_compression_level(ctx_->compression_level());
734  }
735  ctx_->sent_initial_metadata_ = true;
736  }
737  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
738  call_.PerformOps(&finish_ops_);
739  }
740 
741  private:
742  void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
743 
745  ServerContext* ctx_;
747  meta_ops_;
752  finish_ops_;
753 };
754 
755 template <class W>
759  public:
778  virtual void Finish(const Status& status, void* tag) = 0;
779 
791  virtual void WriteAndFinish(const W& msg, WriteOptions options,
792  const Status& status, void* tag) = 0;
793 };
794 
797 template <class W>
799  public:
801  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
802 
810  void SendInitialMetadata(void* tag) override {
811  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
812 
813  meta_ops_.set_output_tag(tag);
814  meta_ops_.SendInitialMetadata(ctx_->initial_metadata_,
815  ctx_->initial_metadata_flags());
816  if (ctx_->compression_level_set()) {
817  meta_ops_.set_compression_level(ctx_->compression_level());
818  }
819  ctx_->sent_initial_metadata_ = true;
820  call_.PerformOps(&meta_ops_);
821  }
822 
823  void Write(const W& msg, void* tag) override {
824  write_ops_.set_output_tag(tag);
825  EnsureInitialMetadataSent(&write_ops_);
826  // TODO(ctiller): don't assert
827  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
828  call_.PerformOps(&write_ops_);
829  }
830 
831  void Write(const W& msg, WriteOptions options, void* tag) override {
832  write_ops_.set_output_tag(tag);
833  if (options.is_last_message()) {
834  options.set_buffer_hint();
835  }
836 
837  EnsureInitialMetadataSent(&write_ops_);
838  // TODO(ctiller): don't assert
839  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
840  call_.PerformOps(&write_ops_);
841  }
842 
850  void WriteAndFinish(const W& msg, WriteOptions options, const Status& status,
851  void* tag) override {
852  write_ops_.set_output_tag(tag);
853  EnsureInitialMetadataSent(&write_ops_);
854  options.set_buffer_hint();
855  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
856  write_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
857  call_.PerformOps(&write_ops_);
858  }
859 
868  void Finish(const Status& status, void* tag) override {
869  finish_ops_.set_output_tag(tag);
870  EnsureInitialMetadataSent(&finish_ops_);
871  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
872  call_.PerformOps(&finish_ops_);
873  }
874 
875  private:
876  void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
877 
878  template <class T>
879  void EnsureInitialMetadataSent(T* ops) {
880  if (!ctx_->sent_initial_metadata_) {
881  ops->SendInitialMetadata(ctx_->initial_metadata_,
882  ctx_->initial_metadata_flags());
883  if (ctx_->compression_level_set()) {
884  ops->set_compression_level(ctx_->compression_level());
885  }
886  ctx_->sent_initial_metadata_ = true;
887  }
888  }
889 
891  ServerContext* ctx_;
893  meta_ops_;
897  write_ops_;
898  ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
900  finish_ops_;
901 };
902 
904 template <class W, class R>
909  public:
929  virtual void Finish(const Status& status, void* tag) = 0;
930 
942  virtual void WriteAndFinish(const W& msg, WriteOptions options,
943  const Status& status, void* tag) = 0;
944 };
945 
950 template <class W, class R>
952  : public ServerAsyncReaderWriterInterface<W, R> {
953  public:
955  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
956 
964  void SendInitialMetadata(void* tag) override {
965  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
966 
967  meta_ops_.set_output_tag(tag);
968  meta_ops_.SendInitialMetadata(ctx_->initial_metadata_,
969  ctx_->initial_metadata_flags());
970  if (ctx_->compression_level_set()) {
971  meta_ops_.set_compression_level(ctx_->compression_level());
972  }
973  ctx_->sent_initial_metadata_ = true;
974  call_.PerformOps(&meta_ops_);
975  }
976 
977  void Read(R* msg, void* tag) override {
978  read_ops_.set_output_tag(tag);
979  read_ops_.RecvMessage(msg);
980  call_.PerformOps(&read_ops_);
981  }
982 
983  void Write(const W& msg, void* tag) override {
984  write_ops_.set_output_tag(tag);
985  EnsureInitialMetadataSent(&write_ops_);
986  // TODO(ctiller): don't assert
987  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
988  call_.PerformOps(&write_ops_);
989  }
990 
991  void Write(const W& msg, WriteOptions options, void* tag) override {
992  write_ops_.set_output_tag(tag);
993  if (options.is_last_message()) {
994  options.set_buffer_hint();
995  }
996  EnsureInitialMetadataSent(&write_ops_);
997  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
998  call_.PerformOps(&write_ops_);
999  }
1000 
1009  void WriteAndFinish(const W& msg, WriteOptions options, const Status& status,
1010  void* tag) override {
1011  write_ops_.set_output_tag(tag);
1012  EnsureInitialMetadataSent(&write_ops_);
1013  options.set_buffer_hint();
1014  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
1015  write_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
1016  call_.PerformOps(&write_ops_);
1017  }
1018 
1027  void Finish(const Status& status, void* tag) override {
1028  finish_ops_.set_output_tag(tag);
1029  EnsureInitialMetadataSent(&finish_ops_);
1030 
1031  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
1032  call_.PerformOps(&finish_ops_);
1033  }
1034 
1035  private:
1036  friend class ::grpc::Server;
1037 
1038  void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
1039 
1040  template <class T>
1041  void EnsureInitialMetadataSent(T* ops) {
1042  if (!ctx_->sent_initial_metadata_) {
1043  ops->SendInitialMetadata(ctx_->initial_metadata_,
1044  ctx_->initial_metadata_flags());
1045  if (ctx_->compression_level_set()) {
1046  ops->set_compression_level(ctx_->compression_level());
1047  }
1048  ctx_->sent_initial_metadata_ = true;
1049  }
1050  }
1051 
1052  ::grpc::internal::Call call_;
1053  ServerContext* ctx_;
1055  meta_ops_;
1060  write_ops_;
1061  ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
1063  finish_ops_;
1064 };
1065 
1066 } // namespace grpc
1067 
1068 #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:491
virtual ~AsyncReaderInterface()
Definition: async_stream.h:86
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
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:138
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:221
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
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
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
Primary implementation of CallOpSetInterface.
Definition: call.h:619
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
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
grpc_call * call() const
Definition: call.h:680
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
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
Definition: async_stream.h:158
Definition: call.h:268
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
An Alarm posts the user provided tag to its associated completion queue upon expiry or cancellation...
Definition: alarm.h:31
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
Server-side interface for asynchronous bi-directional streaming.
Definition: async_stream.h:905
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: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
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:106
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:212
virtual ~ClientAsyncStreamingInterface()
Definition: async_stream.h:37
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&#39;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: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
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
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
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
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
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
Straightforward wrapping of the C call object.
Definition: call.h:660
ServerAsyncReader(ServerContext *ctx)
Definition: async_stream.h:665
Common interface for client side asynchronous writing.
Definition: async_stream.h:288