GRPC C++  1.16.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  // This operator should never be called as the memory should be freed as part
199  // of the arena destruction. It only exists to provide a matching operator
200  // delete to the operator new so that some compilers will not complain (see
201  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
202  // there are no tests catching the compiler warning.
203  static void operator delete(void*, void*) { assert(0); }
204 
205  void StartCall(void* tag) override {
206  assert(!started_);
207  started_ = true;
208  StartCallInternal(tag);
209  }
210 
219  void ReadInitialMetadata(void* tag) override {
220  assert(started_);
221  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
222 
223  meta_ops_.set_output_tag(tag);
224  meta_ops_.RecvInitialMetadata(context_);
225  call_.PerformOps(&meta_ops_);
226  }
227 
228  void Read(R* msg, void* tag) override {
229  assert(started_);
230  read_ops_.set_output_tag(tag);
231  if (!context_->initial_metadata_received_) {
232  read_ops_.RecvInitialMetadata(context_);
233  }
234  read_ops_.RecvMessage(msg);
235  call_.PerformOps(&read_ops_);
236  }
237 
243  void Finish(Status* status, void* tag) override {
244  assert(started_);
245  finish_ops_.set_output_tag(tag);
246  if (!context_->initial_metadata_received_) {
247  finish_ops_.RecvInitialMetadata(context_);
248  }
249  finish_ops_.ClientRecvStatus(context_, status);
250  call_.PerformOps(&finish_ops_);
251  }
252 
253  private:
255  template <class W>
257  const W& request, bool start, void* tag)
258  : context_(context), call_(call), started_(start) {
259  // TODO(ctiller): don't assert
260  GPR_CODEGEN_ASSERT(init_ops_.SendMessage(request).ok());
261  init_ops_.ClientSendClose();
262  if (start) {
263  StartCallInternal(tag);
264  } else {
265  assert(tag == nullptr);
266  }
267  }
268 
269  void StartCallInternal(void* tag) {
270  init_ops_.SendInitialMetadata(context_->send_initial_metadata_,
271  context_->initial_metadata_flags());
272  init_ops_.set_output_tag(tag);
273  call_.PerformOps(&init_ops_);
274  }
275 
276  ClientContext* context_;
278  bool started_;
282  init_ops_;
284  meta_ops_;
287  read_ops_;
288  ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
290  finish_ops_;
291 };
292 
294 template <class W>
298  public:
303  virtual void WritesDone(void* tag) = 0;
304 };
305 
306 namespace internal {
307 template <class W>
309  public:
321  template <class R>
323  CompletionQueue* cq,
324  const ::grpc::internal::RpcMethod& method,
325  ClientContext* context, R* response,
326  bool start, void* tag) {
327  ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
329  call.call(), sizeof(ClientAsyncWriter<W>)))
330  ClientAsyncWriter<W>(call, context, response, start, tag);
331  }
332 };
333 } // namespace internal
334 
338 template <class W>
340  public:
341  // always allocated against a call arena, no memory free required
342  static void operator delete(void* ptr, std::size_t size) {
343  assert(size == sizeof(ClientAsyncWriter));
344  }
345 
346  // This operator should never be called as the memory should be freed as part
347  // of the arena destruction. It only exists to provide a matching operator
348  // delete to the operator new so that some compilers will not complain (see
349  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
350  // there are no tests catching the compiler warning.
351  static void operator delete(void*, void*) { assert(0); }
352 
353  void StartCall(void* tag) override {
354  assert(!started_);
355  started_ = true;
356  StartCallInternal(tag);
357  }
358 
366  void ReadInitialMetadata(void* tag) override {
367  assert(started_);
368  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
369 
370  meta_ops_.set_output_tag(tag);
371  meta_ops_.RecvInitialMetadata(context_);
372  call_.PerformOps(&meta_ops_);
373  }
374 
375  void Write(const W& msg, void* tag) override {
376  assert(started_);
377  write_ops_.set_output_tag(tag);
378  // TODO(ctiller): don't assert
379  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
380  call_.PerformOps(&write_ops_);
381  }
382 
383  void Write(const W& msg, WriteOptions options, void* tag) override {
384  assert(started_);
385  write_ops_.set_output_tag(tag);
386  if (options.is_last_message()) {
387  options.set_buffer_hint();
388  write_ops_.ClientSendClose();
389  }
390  // TODO(ctiller): don't assert
391  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
392  call_.PerformOps(&write_ops_);
393  }
394 
395  void WritesDone(void* tag) override {
396  assert(started_);
397  write_ops_.set_output_tag(tag);
398  write_ops_.ClientSendClose();
399  call_.PerformOps(&write_ops_);
400  }
401 
409  void Finish(Status* status, void* tag) override {
410  assert(started_);
411  finish_ops_.set_output_tag(tag);
412  if (!context_->initial_metadata_received_) {
413  finish_ops_.RecvInitialMetadata(context_);
414  }
415  finish_ops_.ClientRecvStatus(context_, status);
416  call_.PerformOps(&finish_ops_);
417  }
418 
419  private:
421  template <class R>
423  R* response, bool start, void* tag)
424  : context_(context), call_(call), started_(start) {
425  finish_ops_.RecvMessage(response);
426  finish_ops_.AllowNoMessage();
427  if (start) {
428  StartCallInternal(tag);
429  } else {
430  assert(tag == nullptr);
431  }
432  }
433 
434  void StartCallInternal(void* tag) {
435  write_ops_.SendInitialMetadata(context_->send_initial_metadata_,
436  context_->initial_metadata_flags());
437  // if corked bit is set in context, we just keep the initial metadata
438  // buffered up to coalesce with later message send. No op is performed.
439  if (!context_->initial_metadata_corked_) {
440  write_ops_.set_output_tag(tag);
441  call_.PerformOps(&write_ops_);
442  }
443  }
444 
445  ClientContext* context_;
447  bool started_;
449  meta_ops_;
453  write_ops_;
457  finish_ops_;
458 };
459 
463 template <class W, class R>
468  public:
473  virtual void WritesDone(void* tag) = 0;
474 };
475 
476 namespace internal {
477 template <class W, class R>
479  public:
488  ChannelInterface* channel, CompletionQueue* cq,
489  const ::grpc::internal::RpcMethod& method, ClientContext* context,
490  bool start, void* tag) {
491  ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
492 
494  call.call(), sizeof(ClientAsyncReaderWriter<W, R>)))
495  ClientAsyncReaderWriter<W, R>(call, context, start, tag);
496  }
497 };
498 } // namespace internal
499 
504 template <class W, class R>
506  : public ClientAsyncReaderWriterInterface<W, R> {
507  public:
508  // always allocated against a call arena, no memory free required
509  static void operator delete(void* ptr, std::size_t size) {
510  assert(size == sizeof(ClientAsyncReaderWriter));
511  }
512 
513  // This operator should never be called as the memory should be freed as part
514  // of the arena destruction. It only exists to provide a matching operator
515  // delete to the operator new so that some compilers will not complain (see
516  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
517  // there are no tests catching the compiler warning.
518  static void operator delete(void*, void*) { assert(0); }
519 
520  void StartCall(void* tag) override {
521  assert(!started_);
522  started_ = true;
523  StartCallInternal(tag);
524  }
525 
533  void ReadInitialMetadata(void* tag) override {
534  assert(started_);
535  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
536 
537  meta_ops_.set_output_tag(tag);
538  meta_ops_.RecvInitialMetadata(context_);
539  call_.PerformOps(&meta_ops_);
540  }
541 
542  void Read(R* msg, void* tag) override {
543  assert(started_);
544  read_ops_.set_output_tag(tag);
545  if (!context_->initial_metadata_received_) {
546  read_ops_.RecvInitialMetadata(context_);
547  }
548  read_ops_.RecvMessage(msg);
549  call_.PerformOps(&read_ops_);
550  }
551 
552  void Write(const W& msg, void* tag) override {
553  assert(started_);
554  write_ops_.set_output_tag(tag);
555  // TODO(ctiller): don't assert
556  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
557  call_.PerformOps(&write_ops_);
558  }
559 
560  void Write(const W& msg, WriteOptions options, void* tag) override {
561  assert(started_);
562  write_ops_.set_output_tag(tag);
563  if (options.is_last_message()) {
564  options.set_buffer_hint();
565  write_ops_.ClientSendClose();
566  }
567  // TODO(ctiller): don't assert
568  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
569  call_.PerformOps(&write_ops_);
570  }
571 
572  void WritesDone(void* tag) override {
573  assert(started_);
574  write_ops_.set_output_tag(tag);
575  write_ops_.ClientSendClose();
576  call_.PerformOps(&write_ops_);
577  }
578 
583  void Finish(Status* status, void* tag) override {
584  assert(started_);
585  finish_ops_.set_output_tag(tag);
586  if (!context_->initial_metadata_received_) {
587  finish_ops_.RecvInitialMetadata(context_);
588  }
589  finish_ops_.ClientRecvStatus(context_, status);
590  call_.PerformOps(&finish_ops_);
591  }
592 
593  private:
596  bool start, void* tag)
597  : context_(context), call_(call), started_(start) {
598  if (start) {
599  StartCallInternal(tag);
600  } else {
601  assert(tag == nullptr);
602  }
603  }
604 
605  void StartCallInternal(void* tag) {
606  write_ops_.SendInitialMetadata(context_->send_initial_metadata_,
607  context_->initial_metadata_flags());
608  // if corked bit is set in context, we just keep the initial metadata
609  // buffered up to coalesce with later message send. No op is performed.
610  if (!context_->initial_metadata_corked_) {
611  write_ops_.set_output_tag(tag);
612  call_.PerformOps(&write_ops_);
613  }
614  }
615 
616  ClientContext* context_;
618  bool started_;
620  meta_ops_;
623  read_ops_;
627  write_ops_;
628  ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
630  finish_ops_;
631 };
632 
633 template <class W, class R>
637  public:
657  virtual void Finish(const W& msg, const Status& status, void* tag) = 0;
658 
677  virtual void FinishWithError(const Status& status, void* tag) = 0;
678 };
679 
683 template <class W, class R>
684 class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
685  public:
687  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
688 
694  void SendInitialMetadata(void* tag) override {
695  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
696 
697  meta_ops_.set_output_tag(tag);
698  meta_ops_.SendInitialMetadata(ctx_->initial_metadata_,
699  ctx_->initial_metadata_flags());
700  if (ctx_->compression_level_set()) {
701  meta_ops_.set_compression_level(ctx_->compression_level());
702  }
703  ctx_->sent_initial_metadata_ = true;
704  call_.PerformOps(&meta_ops_);
705  }
706 
707  void Read(R* msg, void* tag) override {
708  read_ops_.set_output_tag(tag);
709  read_ops_.RecvMessage(msg);
710  call_.PerformOps(&read_ops_);
711  }
712 
721  void Finish(const W& msg, const Status& status, void* tag) override {
722  finish_ops_.set_output_tag(tag);
723  if (!ctx_->sent_initial_metadata_) {
724  finish_ops_.SendInitialMetadata(ctx_->initial_metadata_,
725  ctx_->initial_metadata_flags());
726  if (ctx_->compression_level_set()) {
727  finish_ops_.set_compression_level(ctx_->compression_level());
728  }
729  ctx_->sent_initial_metadata_ = true;
730  }
731  // The response is dropped if the status is not OK.
732  if (status.ok()) {
733  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_,
734  finish_ops_.SendMessage(msg));
735  } else {
736  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
737  }
738  call_.PerformOps(&finish_ops_);
739  }
740 
747  void FinishWithError(const Status& status, void* tag) override {
748  GPR_CODEGEN_ASSERT(!status.ok());
749  finish_ops_.set_output_tag(tag);
750  if (!ctx_->sent_initial_metadata_) {
751  finish_ops_.SendInitialMetadata(ctx_->initial_metadata_,
752  ctx_->initial_metadata_flags());
753  if (ctx_->compression_level_set()) {
754  finish_ops_.set_compression_level(ctx_->compression_level());
755  }
756  ctx_->sent_initial_metadata_ = true;
757  }
758  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
759  call_.PerformOps(&finish_ops_);
760  }
761 
762  private:
763  void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
764 
766  ServerContext* ctx_;
768  meta_ops_;
773  finish_ops_;
774 };
775 
776 template <class W>
780  public:
799  virtual void Finish(const Status& status, void* tag) = 0;
800 
812  virtual void WriteAndFinish(const W& msg, WriteOptions options,
813  const Status& status, void* tag) = 0;
814 };
815 
818 template <class W>
820  public:
822  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
823 
831  void SendInitialMetadata(void* tag) override {
832  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
833 
834  meta_ops_.set_output_tag(tag);
835  meta_ops_.SendInitialMetadata(ctx_->initial_metadata_,
836  ctx_->initial_metadata_flags());
837  if (ctx_->compression_level_set()) {
838  meta_ops_.set_compression_level(ctx_->compression_level());
839  }
840  ctx_->sent_initial_metadata_ = true;
841  call_.PerformOps(&meta_ops_);
842  }
843 
844  void Write(const W& msg, void* tag) override {
845  write_ops_.set_output_tag(tag);
846  EnsureInitialMetadataSent(&write_ops_);
847  // TODO(ctiller): don't assert
848  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
849  call_.PerformOps(&write_ops_);
850  }
851 
852  void Write(const W& msg, WriteOptions options, void* tag) override {
853  write_ops_.set_output_tag(tag);
854  if (options.is_last_message()) {
855  options.set_buffer_hint();
856  }
857 
858  EnsureInitialMetadataSent(&write_ops_);
859  // TODO(ctiller): don't assert
860  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
861  call_.PerformOps(&write_ops_);
862  }
863 
871  void WriteAndFinish(const W& msg, WriteOptions options, const Status& status,
872  void* tag) override {
873  write_ops_.set_output_tag(tag);
874  EnsureInitialMetadataSent(&write_ops_);
875  options.set_buffer_hint();
876  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
877  write_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
878  call_.PerformOps(&write_ops_);
879  }
880 
889  void Finish(const Status& status, void* tag) override {
890  finish_ops_.set_output_tag(tag);
891  EnsureInitialMetadataSent(&finish_ops_);
892  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
893  call_.PerformOps(&finish_ops_);
894  }
895 
896  private:
897  void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
898 
899  template <class T>
900  void EnsureInitialMetadataSent(T* ops) {
901  if (!ctx_->sent_initial_metadata_) {
902  ops->SendInitialMetadata(ctx_->initial_metadata_,
903  ctx_->initial_metadata_flags());
904  if (ctx_->compression_level_set()) {
905  ops->set_compression_level(ctx_->compression_level());
906  }
907  ctx_->sent_initial_metadata_ = true;
908  }
909  }
910 
912  ServerContext* ctx_;
914  meta_ops_;
918  write_ops_;
919  ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
921  finish_ops_;
922 };
923 
925 template <class W, class R>
930  public:
950  virtual void Finish(const Status& status, void* tag) = 0;
951 
963  virtual void WriteAndFinish(const W& msg, WriteOptions options,
964  const Status& status, void* tag) = 0;
965 };
966 
971 template <class W, class R>
973  : public ServerAsyncReaderWriterInterface<W, R> {
974  public:
976  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
977 
985  void SendInitialMetadata(void* tag) override {
986  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
987 
988  meta_ops_.set_output_tag(tag);
989  meta_ops_.SendInitialMetadata(ctx_->initial_metadata_,
990  ctx_->initial_metadata_flags());
991  if (ctx_->compression_level_set()) {
992  meta_ops_.set_compression_level(ctx_->compression_level());
993  }
994  ctx_->sent_initial_metadata_ = true;
995  call_.PerformOps(&meta_ops_);
996  }
997 
998  void Read(R* msg, void* tag) override {
999  read_ops_.set_output_tag(tag);
1000  read_ops_.RecvMessage(msg);
1001  call_.PerformOps(&read_ops_);
1002  }
1003 
1004  void Write(const W& msg, void* tag) override {
1005  write_ops_.set_output_tag(tag);
1006  EnsureInitialMetadataSent(&write_ops_);
1007  // TODO(ctiller): don't assert
1008  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
1009  call_.PerformOps(&write_ops_);
1010  }
1011 
1012  void Write(const W& msg, WriteOptions options, void* tag) override {
1013  write_ops_.set_output_tag(tag);
1014  if (options.is_last_message()) {
1015  options.set_buffer_hint();
1016  }
1017  EnsureInitialMetadataSent(&write_ops_);
1018  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
1019  call_.PerformOps(&write_ops_);
1020  }
1021 
1030  void WriteAndFinish(const W& msg, WriteOptions options, const Status& status,
1031  void* tag) override {
1032  write_ops_.set_output_tag(tag);
1033  EnsureInitialMetadataSent(&write_ops_);
1034  options.set_buffer_hint();
1035  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
1036  write_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
1037  call_.PerformOps(&write_ops_);
1038  }
1039 
1048  void Finish(const Status& status, void* tag) override {
1049  finish_ops_.set_output_tag(tag);
1050  EnsureInitialMetadataSent(&finish_ops_);
1051 
1052  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
1053  call_.PerformOps(&finish_ops_);
1054  }
1055 
1056  private:
1057  friend class ::grpc::Server;
1058 
1059  void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
1060 
1061  template <class T>
1062  void EnsureInitialMetadataSent(T* ops) {
1063  if (!ctx_->sent_initial_metadata_) {
1064  ops->SendInitialMetadata(ctx_->initial_metadata_,
1065  ctx_->initial_metadata_flags());
1066  if (ctx_->compression_level_set()) {
1067  ops->set_compression_level(ctx_->compression_level());
1068  }
1069  ctx_->sent_initial_metadata_ = true;
1070  }
1071  }
1072 
1073  ::grpc::internal::Call call_;
1074  ServerContext* ctx_;
1076  meta_ops_;
1081  write_ops_;
1082  ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
1084  finish_ops_;
1085 };
1086 
1087 } // namespace grpc
1088 
1089 #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:505
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:707
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
#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:228
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:322
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:487
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
Primary implementation of CallOpSetInterface.
Definition: call.h:618
Async server-side API for doing bidirectional streaming RPCs, where the incoming message stream comin...
Definition: async_stream.h:972
void FinishWithError(const Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:747
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:1012
void Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:583
Definition: async_stream.h:634
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:243
grpc_call * call() const
Definition: call.h:688
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:164
Definition: async_stream.h:308
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:844
Async server-side API for doing server streaming RPCs, where the outgoing message stream from the ser...
Definition: async_stream.h:819
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:721
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:1048
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:560
ServerAsyncReaderWriter(ServerContext *ctx)
Definition: async_stream.h:975
Definition: async_stream.h:158
Definition: call.h:266
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:985
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:464
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:353
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:205
Codegen interface for grpc::Channel.
Definition: channel_interface.h:57
ServerAsyncWriter(ServerContext *ctx)
Definition: async_stream.h:821
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:831
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:339
Server-side interface for asynchronous bi-directional streaming.
Definition: async_stream.h:926
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:572
A ServerContext allows the person implementing a service handler to:
Definition: server_context.h:97
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:694
Per-message write options.
Definition: call.h:81
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:852
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:375
void WriteAndFinish(const W &msg, WriteOptions options, const Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.WriteAndFinish method for semantics.
Definition: async_stream.h:1030
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:95
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:219
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:383
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:889
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics of this method...
Definition: async_stream.h:533
Definition: async_stream.h:777
void Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:409
void WritesDone(void *tag) override
Signal the client is done with the writes (half-close the client stream).
Definition: async_stream.h:395
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:185
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:552
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:998
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:1004
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:542
void WriteAndFinish(const W &msg, WriteOptions options, const Status &status, void *tag) override
See the ServerAsyncWriterInterface.WriteAndFinish method for semantics.
Definition: async_stream.h:871
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:520
Async server-side API for doing client-streaming RPCs, where the incoming message stream from the cli...
Definition: async_stream.h:684
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:366
Common interface for all client side asynchronous streaming.
Definition: async_stream.h:35
Straightforward wrapping of the C call object.
Definition: call.h:668
ServerAsyncReader(ServerContext *ctx)
Definition: async_stream.h:686
Common interface for client side asynchronous writing.
Definition: async_stream.h:295