GRPC C++  1.19.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 
122  virtual void Write(const W& msg, void* tag) = 0;
123 
139  virtual void Write(const W& msg, WriteOptions options, void* tag) = 0;
140 
159  void WriteLast(const W& msg, WriteOptions options, void* tag) {
160  Write(msg, options.set_last_message(), tag);
161  }
162 };
163 
164 } // namespace internal
165 
166 template <class R>
169  public internal::AsyncReaderInterface<R> {};
170 
171 namespace internal {
172 template <class R>
174  public:
182  template <class W>
184  CompletionQueue* cq,
185  const ::grpc::internal::RpcMethod& method,
186  ClientContext* context, const W& request,
187  bool start, void* tag) {
188  ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
190  call.call(), sizeof(ClientAsyncReader<R>)))
191  ClientAsyncReader<R>(call, context, request, start, tag);
192  }
193 };
194 } // namespace internal
195 
199 template <class R>
201  public:
202  // always allocated against a call arena, no memory free required
203  static void operator delete(void* ptr, std::size_t size) {
204  assert(size == sizeof(ClientAsyncReader));
205  }
206 
207  // This operator should never be called as the memory should be freed as part
208  // of the arena destruction. It only exists to provide a matching operator
209  // delete to the operator new so that some compilers will not complain (see
210  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
211  // there are no tests catching the compiler warning.
212  static void operator delete(void*, void*) { assert(0); }
213 
214  void StartCall(void* tag) override {
215  assert(!started_);
216  started_ = true;
217  StartCallInternal(tag);
218  }
219 
228  void ReadInitialMetadata(void* tag) override {
229  assert(started_);
230  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
231 
232  meta_ops_.set_output_tag(tag);
233  meta_ops_.RecvInitialMetadata(context_);
234  call_.PerformOps(&meta_ops_);
235  }
236 
237  void Read(R* msg, void* tag) override {
238  assert(started_);
239  read_ops_.set_output_tag(tag);
240  if (!context_->initial_metadata_received_) {
241  read_ops_.RecvInitialMetadata(context_);
242  }
243  read_ops_.RecvMessage(msg);
244  call_.PerformOps(&read_ops_);
245  }
246 
252  void Finish(Status* status, void* tag) override {
253  assert(started_);
254  finish_ops_.set_output_tag(tag);
255  if (!context_->initial_metadata_received_) {
256  finish_ops_.RecvInitialMetadata(context_);
257  }
258  finish_ops_.ClientRecvStatus(context_, status);
259  call_.PerformOps(&finish_ops_);
260  }
261 
262  private:
264  template <class W>
266  const W& request, bool start, void* tag)
267  : context_(context), call_(call), started_(start) {
268  // TODO(ctiller): don't assert
269  GPR_CODEGEN_ASSERT(init_ops_.SendMessage(request).ok());
270  init_ops_.ClientSendClose();
271  if (start) {
272  StartCallInternal(tag);
273  } else {
274  assert(tag == nullptr);
275  }
276  }
277 
278  void StartCallInternal(void* tag) {
279  init_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
280  context_->initial_metadata_flags());
281  init_ops_.set_output_tag(tag);
282  call_.PerformOps(&init_ops_);
283  }
284 
285  ClientContext* context_;
287  bool started_;
291  init_ops_;
293  meta_ops_;
296  read_ops_;
297  ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
299  finish_ops_;
300 };
301 
303 template <class W>
307  public:
312  virtual void WritesDone(void* tag) = 0;
313 };
314 
315 namespace internal {
316 template <class W>
318  public:
330  template <class R>
332  CompletionQueue* cq,
333  const ::grpc::internal::RpcMethod& method,
334  ClientContext* context, R* response,
335  bool start, void* tag) {
336  ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
338  call.call(), sizeof(ClientAsyncWriter<W>)))
339  ClientAsyncWriter<W>(call, context, response, start, tag);
340  }
341 };
342 } // namespace internal
343 
347 template <class W>
349  public:
350  // always allocated against a call arena, no memory free required
351  static void operator delete(void* ptr, std::size_t size) {
352  assert(size == sizeof(ClientAsyncWriter));
353  }
354 
355  // This operator should never be called as the memory should be freed as part
356  // of the arena destruction. It only exists to provide a matching operator
357  // delete to the operator new so that some compilers will not complain (see
358  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
359  // there are no tests catching the compiler warning.
360  static void operator delete(void*, void*) { assert(0); }
361 
362  void StartCall(void* tag) override {
363  assert(!started_);
364  started_ = true;
365  StartCallInternal(tag);
366  }
367 
375  void ReadInitialMetadata(void* tag) override {
376  assert(started_);
377  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
378 
379  meta_ops_.set_output_tag(tag);
380  meta_ops_.RecvInitialMetadata(context_);
381  call_.PerformOps(&meta_ops_);
382  }
383 
384  void Write(const W& msg, void* tag) override {
385  assert(started_);
386  write_ops_.set_output_tag(tag);
387  // TODO(ctiller): don't assert
388  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
389  call_.PerformOps(&write_ops_);
390  }
391 
392  void Write(const W& msg, WriteOptions options, void* tag) override {
393  assert(started_);
394  write_ops_.set_output_tag(tag);
395  if (options.is_last_message()) {
396  options.set_buffer_hint();
397  write_ops_.ClientSendClose();
398  }
399  // TODO(ctiller): don't assert
400  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
401  call_.PerformOps(&write_ops_);
402  }
403 
404  void WritesDone(void* tag) override {
405  assert(started_);
406  write_ops_.set_output_tag(tag);
407  write_ops_.ClientSendClose();
408  call_.PerformOps(&write_ops_);
409  }
410 
418  void Finish(Status* status, void* tag) override {
419  assert(started_);
420  finish_ops_.set_output_tag(tag);
421  if (!context_->initial_metadata_received_) {
422  finish_ops_.RecvInitialMetadata(context_);
423  }
424  finish_ops_.ClientRecvStatus(context_, status);
425  call_.PerformOps(&finish_ops_);
426  }
427 
428  private:
430  template <class R>
432  R* response, bool start, void* tag)
433  : context_(context), call_(call), started_(start) {
434  finish_ops_.RecvMessage(response);
435  finish_ops_.AllowNoMessage();
436  if (start) {
437  StartCallInternal(tag);
438  } else {
439  assert(tag == nullptr);
440  }
441  }
442 
443  void StartCallInternal(void* tag) {
444  write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
445  context_->initial_metadata_flags());
446  // if corked bit is set in context, we just keep the initial metadata
447  // buffered up to coalesce with later message send. No op is performed.
448  if (!context_->initial_metadata_corked_) {
449  write_ops_.set_output_tag(tag);
450  call_.PerformOps(&write_ops_);
451  }
452  }
453 
454  ClientContext* context_;
456  bool started_;
458  meta_ops_;
462  write_ops_;
466  finish_ops_;
467 };
468 
472 template <class W, class R>
477  public:
482  virtual void WritesDone(void* tag) = 0;
483 };
484 
485 namespace internal {
486 template <class W, class R>
488  public:
497  ChannelInterface* channel, CompletionQueue* cq,
498  const ::grpc::internal::RpcMethod& method, ClientContext* context,
499  bool start, void* tag) {
500  ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
501 
503  call.call(), sizeof(ClientAsyncReaderWriter<W, R>)))
504  ClientAsyncReaderWriter<W, R>(call, context, start, tag);
505  }
506 };
507 } // namespace internal
508 
513 template <class W, class R>
515  : public ClientAsyncReaderWriterInterface<W, R> {
516  public:
517  // always allocated against a call arena, no memory free required
518  static void operator delete(void* ptr, std::size_t size) {
519  assert(size == sizeof(ClientAsyncReaderWriter));
520  }
521 
522  // This operator should never be called as the memory should be freed as part
523  // of the arena destruction. It only exists to provide a matching operator
524  // delete to the operator new so that some compilers will not complain (see
525  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
526  // there are no tests catching the compiler warning.
527  static void operator delete(void*, void*) { assert(0); }
528 
529  void StartCall(void* tag) override {
530  assert(!started_);
531  started_ = true;
532  StartCallInternal(tag);
533  }
534 
542  void ReadInitialMetadata(void* tag) override {
543  assert(started_);
544  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
545 
546  meta_ops_.set_output_tag(tag);
547  meta_ops_.RecvInitialMetadata(context_);
548  call_.PerformOps(&meta_ops_);
549  }
550 
551  void Read(R* msg, void* tag) override {
552  assert(started_);
553  read_ops_.set_output_tag(tag);
554  if (!context_->initial_metadata_received_) {
555  read_ops_.RecvInitialMetadata(context_);
556  }
557  read_ops_.RecvMessage(msg);
558  call_.PerformOps(&read_ops_);
559  }
560 
561  void Write(const W& msg, void* tag) override {
562  assert(started_);
563  write_ops_.set_output_tag(tag);
564  // TODO(ctiller): don't assert
565  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
566  call_.PerformOps(&write_ops_);
567  }
568 
569  void Write(const W& msg, WriteOptions options, void* tag) override {
570  assert(started_);
571  write_ops_.set_output_tag(tag);
572  if (options.is_last_message()) {
573  options.set_buffer_hint();
574  write_ops_.ClientSendClose();
575  }
576  // TODO(ctiller): don't assert
577  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
578  call_.PerformOps(&write_ops_);
579  }
580 
581  void WritesDone(void* tag) override {
582  assert(started_);
583  write_ops_.set_output_tag(tag);
584  write_ops_.ClientSendClose();
585  call_.PerformOps(&write_ops_);
586  }
587 
592  void Finish(Status* status, void* tag) override {
593  assert(started_);
594  finish_ops_.set_output_tag(tag);
595  if (!context_->initial_metadata_received_) {
596  finish_ops_.RecvInitialMetadata(context_);
597  }
598  finish_ops_.ClientRecvStatus(context_, status);
599  call_.PerformOps(&finish_ops_);
600  }
601 
602  private:
605  bool start, void* tag)
606  : context_(context), call_(call), started_(start) {
607  if (start) {
608  StartCallInternal(tag);
609  } else {
610  assert(tag == nullptr);
611  }
612  }
613 
614  void StartCallInternal(void* tag) {
615  write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
616  context_->initial_metadata_flags());
617  // if corked bit is set in context, we just keep the initial metadata
618  // buffered up to coalesce with later message send. No op is performed.
619  if (!context_->initial_metadata_corked_) {
620  write_ops_.set_output_tag(tag);
621  call_.PerformOps(&write_ops_);
622  }
623  }
624 
625  ClientContext* context_;
627  bool started_;
629  meta_ops_;
632  read_ops_;
636  write_ops_;
637  ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
639  finish_ops_;
640 };
641 
642 template <class W, class R>
646  public:
669  virtual void Finish(const W& msg, const Status& status, void* tag) = 0;
670 
692  virtual void FinishWithError(const Status& status, void* tag) = 0;
693 };
694 
698 template <class W, class R>
699 class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
700  public:
702  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
703 
709  void SendInitialMetadata(void* tag) override {
710  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
711 
712  meta_ops_.set_output_tag(tag);
713  meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
714  ctx_->initial_metadata_flags());
715  if (ctx_->compression_level_set()) {
716  meta_ops_.set_compression_level(ctx_->compression_level());
717  }
718  ctx_->sent_initial_metadata_ = true;
719  call_.PerformOps(&meta_ops_);
720  }
721 
722  void Read(R* msg, void* tag) override {
723  read_ops_.set_output_tag(tag);
724  read_ops_.RecvMessage(msg);
725  call_.PerformOps(&read_ops_);
726  }
727 
739  void Finish(const W& msg, const Status& status, void* tag) override {
740  finish_ops_.set_output_tag(tag);
741  if (!ctx_->sent_initial_metadata_) {
742  finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
743  ctx_->initial_metadata_flags());
744  if (ctx_->compression_level_set()) {
745  finish_ops_.set_compression_level(ctx_->compression_level());
746  }
747  ctx_->sent_initial_metadata_ = true;
748  }
749  // The response is dropped if the status is not OK.
750  if (status.ok()) {
751  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_,
752  finish_ops_.SendMessage(msg));
753  } else {
754  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
755  }
756  call_.PerformOps(&finish_ops_);
757  }
758 
768  void FinishWithError(const Status& status, void* tag) override {
769  GPR_CODEGEN_ASSERT(!status.ok());
770  finish_ops_.set_output_tag(tag);
771  if (!ctx_->sent_initial_metadata_) {
772  finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
773  ctx_->initial_metadata_flags());
774  if (ctx_->compression_level_set()) {
775  finish_ops_.set_compression_level(ctx_->compression_level());
776  }
777  ctx_->sent_initial_metadata_ = true;
778  }
779  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
780  call_.PerformOps(&finish_ops_);
781  }
782 
783  private:
784  void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
785 
787  ServerContext* ctx_;
789  meta_ops_;
794  finish_ops_;
795 };
796 
797 template <class W>
801  public:
823  virtual void Finish(const Status& status, void* tag) = 0;
824 
839  virtual void WriteAndFinish(const W& msg, WriteOptions options,
840  const Status& status, void* tag) = 0;
841 };
842 
845 template <class W>
847  public:
849  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
850 
858  void SendInitialMetadata(void* tag) override {
859  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
860 
861  meta_ops_.set_output_tag(tag);
862  meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
863  ctx_->initial_metadata_flags());
864  if (ctx_->compression_level_set()) {
865  meta_ops_.set_compression_level(ctx_->compression_level());
866  }
867  ctx_->sent_initial_metadata_ = true;
868  call_.PerformOps(&meta_ops_);
869  }
870 
871  void Write(const W& msg, void* tag) override {
872  write_ops_.set_output_tag(tag);
873  EnsureInitialMetadataSent(&write_ops_);
874  // TODO(ctiller): don't assert
875  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
876  call_.PerformOps(&write_ops_);
877  }
878 
879  void Write(const W& msg, WriteOptions options, void* tag) override {
880  write_ops_.set_output_tag(tag);
881  if (options.is_last_message()) {
882  options.set_buffer_hint();
883  }
884 
885  EnsureInitialMetadataSent(&write_ops_);
886  // TODO(ctiller): don't assert
887  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
888  call_.PerformOps(&write_ops_);
889  }
890 
901  void WriteAndFinish(const W& msg, WriteOptions options, const Status& status,
902  void* tag) override {
903  write_ops_.set_output_tag(tag);
904  EnsureInitialMetadataSent(&write_ops_);
905  options.set_buffer_hint();
906  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
907  write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
908  call_.PerformOps(&write_ops_);
909  }
910 
922  void Finish(const Status& status, void* tag) override {
923  finish_ops_.set_output_tag(tag);
924  EnsureInitialMetadataSent(&finish_ops_);
925  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
926  call_.PerformOps(&finish_ops_);
927  }
928 
929  private:
930  void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
931 
932  template <class T>
933  void EnsureInitialMetadataSent(T* ops) {
934  if (!ctx_->sent_initial_metadata_) {
935  ops->SendInitialMetadata(&ctx_->initial_metadata_,
936  ctx_->initial_metadata_flags());
937  if (ctx_->compression_level_set()) {
938  ops->set_compression_level(ctx_->compression_level());
939  }
940  ctx_->sent_initial_metadata_ = true;
941  }
942  }
943 
945  ServerContext* ctx_;
947  meta_ops_;
951  write_ops_;
952  ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
954  finish_ops_;
955 };
956 
958 template <class W, class R>
963  public:
986  virtual void Finish(const Status& status, void* tag) = 0;
987 
1002  virtual void WriteAndFinish(const W& msg, WriteOptions options,
1003  const Status& status, void* tag) = 0;
1004 };
1005 
1010 template <class W, class R>
1012  : public ServerAsyncReaderWriterInterface<W, R> {
1013  public:
1015  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
1016 
1024  void SendInitialMetadata(void* tag) override {
1025  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
1026 
1027  meta_ops_.set_output_tag(tag);
1028  meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
1029  ctx_->initial_metadata_flags());
1030  if (ctx_->compression_level_set()) {
1031  meta_ops_.set_compression_level(ctx_->compression_level());
1032  }
1033  ctx_->sent_initial_metadata_ = true;
1034  call_.PerformOps(&meta_ops_);
1035  }
1036 
1037  void Read(R* msg, void* tag) override {
1038  read_ops_.set_output_tag(tag);
1039  read_ops_.RecvMessage(msg);
1040  call_.PerformOps(&read_ops_);
1041  }
1042 
1043  void Write(const W& msg, void* tag) override {
1044  write_ops_.set_output_tag(tag);
1045  EnsureInitialMetadataSent(&write_ops_);
1046  // TODO(ctiller): don't assert
1047  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
1048  call_.PerformOps(&write_ops_);
1049  }
1050 
1051  void Write(const W& msg, WriteOptions options, void* tag) override {
1052  write_ops_.set_output_tag(tag);
1053  if (options.is_last_message()) {
1054  options.set_buffer_hint();
1055  }
1056  EnsureInitialMetadataSent(&write_ops_);
1057  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
1058  call_.PerformOps(&write_ops_);
1059  }
1060 
1069  //
1072  void WriteAndFinish(const W& msg, WriteOptions options, const Status& status,
1073  void* tag) override {
1074  write_ops_.set_output_tag(tag);
1075  EnsureInitialMetadataSent(&write_ops_);
1076  options.set_buffer_hint();
1077  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
1078  write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
1079  call_.PerformOps(&write_ops_);
1080  }
1081 
1090  //
1093  void Finish(const Status& status, void* tag) override {
1094  finish_ops_.set_output_tag(tag);
1095  EnsureInitialMetadataSent(&finish_ops_);
1096 
1097  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
1098  call_.PerformOps(&finish_ops_);
1099  }
1100 
1101  private:
1102  friend class ::grpc::Server;
1103 
1104  void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
1105 
1106  template <class T>
1107  void EnsureInitialMetadataSent(T* ops) {
1108  if (!ctx_->sent_initial_metadata_) {
1109  ops->SendInitialMetadata(&ctx_->initial_metadata_,
1110  ctx_->initial_metadata_flags());
1111  if (ctx_->compression_level_set()) {
1112  ops->set_compression_level(ctx_->compression_level());
1113  }
1114  ctx_->sent_initial_metadata_ = true;
1115  }
1116  }
1117 
1118  ::grpc::internal::Call call_;
1119  ServerContext* ctx_;
1121  meta_ops_;
1126  write_ops_;
1127  ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
1129  finish_ops_;
1130 };
1131 
1132 } // namespace grpc
1133 
1134 #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:514
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:722
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:125
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:141
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:237
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:331
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:496
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:164
Primary implementation of CallOpSetInterface.
Definition: call_op_set.h:827
Async server-side API for doing bidirectional streaming RPCs, where the incoming message stream comin...
Definition: async_stream.h:1011
void FinishWithError(const Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:768
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:1051
void Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:592
Definition: async_stream.h:643
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:252
grpc_call * call() const
Definition: call.h:70
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:174
Definition: async_stream.h:317
Definition: async_stream.h:173
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:871
Async server-side API for doing server streaming RPCs, where the outgoing message stream from the ser...
Definition: async_stream.h:846
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:183
void Finish(const W &msg, const Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:739
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:1093
Definition: call_op_set.h:635
Definition: call_op_set.h:223
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:569
ServerAsyncReaderWriter(ServerContext *ctx)
Definition: async_stream.h:1014
Definition: call_op_set.h:702
Definition: async_stream.h:167
Definition: call_op_set.h:293
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:1024
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:473
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
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:362
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:214
Codegen interface for grpc::Channel.
Definition: channel_interface.h:65
ServerAsyncWriter(ServerContext *ctx)
Definition: async_stream.h:848
CoreCodegenInterface * g_core_codegen_interface
Definition: call_op_set.h:50
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:858
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:159
Async API on the client side for doing client-streaming RPCs, where the outgoing message stream going...
Definition: async_stream.h:348
Server-side interface for asynchronous bi-directional streaming.
Definition: async_stream.h:959
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:581
A ServerContext allows the person implementing a service handler to:
Definition: server_context.h:109
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:709
Per-message write options.
Definition: call_op_set.h:85
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:879
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:384
void WriteAndFinish(const W &msg, WriteOptions options, const Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.WriteAndFinish method for semantics.
Definition: async_stream.h:1072
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:95
Definition: call_op_set.h:600
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:228
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:392
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:922
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics of this method...
Definition: async_stream.h:542
Definition: async_stream.h:798
void Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:418
void WritesDone(void *tag) override
Signal the client is done with the writes (half-close the client stream).
Definition: async_stream.h:404
Definition: call_op_set.h:522
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:189
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:561
Definition: call_op_set.h:750
Async client-side API for doing server-streaming RPCs, where the incoming message stream coming from ...
Definition: async_stream.h:200
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:1037
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:1043
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:551
void WriteAndFinish(const W &msg, WriteOptions options, const Status &status, void *tag) override
See the ServerAsyncWriterInterface.WriteAndFinish method for semantics.
Definition: async_stream.h:901
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:529
Async server-side API for doing client-streaming RPCs, where the incoming message stream from the cli...
Definition: async_stream.h:699
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:375
Common interface for all client side asynchronous streaming.
Definition: async_stream.h:35
Straightforward wrapping of the C call object.
Definition: call.h:36
ServerAsyncReader(ServerContext *ctx)
Definition: async_stream.h:701
Common interface for client side asynchronous writing.
Definition: async_stream.h:304