impl/codegen/client_callback.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2019 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 #ifndef GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_H
19 #define GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_H
20 
21 // IWYU pragma: private, include <grpcpp/support/client_callback.h>
22 
23 #include <atomic>
24 #include <functional>
25 
34 
35 namespace grpc {
36 class Channel;
37 class ClientContext;
38 
39 namespace internal {
40 class RpcMethod;
41 
48 template <class InputMessage, class OutputMessage,
49  class BaseInputMessage = InputMessage,
50  class BaseOutputMessage = OutputMessage>
54  const InputMessage* request, OutputMessage* result,
55  std::function<void(grpc::Status)> on_completion) {
57  "Invalid input message specification");
59  "Invalid output message specification");
61  channel, method, context, request, result, on_completion);
62 }
63 
64 template <class InputMessage, class OutputMessage>
65 class CallbackUnaryCallImpl {
66  public:
70  const InputMessage* request, OutputMessage* result,
71  std::function<void(grpc::Status)> on_completion) {
72  grpc::CompletionQueue* cq = channel->CallbackCQ();
73  GPR_CODEGEN_ASSERT(cq != nullptr);
75 
76  using FullCallOpSet = grpc::internal::CallOpSet<
83 
84  struct OpSetAndTag {
85  FullCallOpSet opset;
87  };
88  const size_t alloc_sz = sizeof(OpSetAndTag);
89  auto* const alloced = static_cast<OpSetAndTag*>(
91  alloc_sz));
92  auto* ops = new (&alloced->opset) FullCallOpSet;
93  auto* tag = new (&alloced->tag)
94  grpc::internal::CallbackWithStatusTag(call.call(), on_completion, ops);
95 
96  // TODO(vjpai): Unify code with sync API as much as possible
97  grpc::Status s = ops->SendMessagePtr(request);
98  if (!s.ok()) {
99  tag->force_run(s);
100  return;
101  }
102  ops->SendInitialMetadata(&context->send_initial_metadata_,
104  ops->RecvInitialMetadata(context);
105  ops->RecvMessage(result);
106  ops->AllowNoMessage();
107  ops->ClientSendClose();
108  ops->ClientRecvStatus(context, tag->status_ptr());
109  ops->set_core_cq_tag(tag);
110  call.PerformOps(ops);
111  }
112 };
113 
114 // Base class for public API classes.
116  public:
117  virtual ~ClientReactor() = default;
118 
126  virtual void OnDone(const grpc::Status& /*s*/) = 0;
127 
135  virtual void InternalScheduleOnDone(grpc::Status s);
136 
144  virtual bool InternalTrailersOnly(const grpc_call* call) const;
145 };
146 
147 } // namespace internal
148 
149 // Forward declarations
150 template <class Request, class Response>
152 template <class Response>
154 template <class Request>
156 class ClientUnaryReactor;
157 
158 // NOTE: The streaming objects are not actually implemented in the public API.
159 // These interfaces are provided for mocking only. Typical applications
160 // will interact exclusively with the reactors that they define.
161 template <class Request, class Response>
163  public:
165  virtual void StartCall() = 0;
166  virtual void Write(const Request* req, grpc::WriteOptions options) = 0;
167  virtual void WritesDone() = 0;
168  virtual void Read(Response* resp) = 0;
169  virtual void AddHold(int holds) = 0;
170  virtual void RemoveHold() = 0;
171 
172  protected:
174  reactor->BindStream(this);
175  }
176 };
177 
178 template <class Response>
180  public:
182  virtual void StartCall() = 0;
183  virtual void Read(Response* resp) = 0;
184  virtual void AddHold(int holds) = 0;
185  virtual void RemoveHold() = 0;
186 
187  protected:
189  reactor->BindReader(this);
190  }
191 };
192 
193 template <class Request>
195  public:
197  virtual void StartCall() = 0;
198  void Write(const Request* req) { Write(req, grpc::WriteOptions()); }
199  virtual void Write(const Request* req, grpc::WriteOptions options) = 0;
201  Write(req, options.set_last_message());
202  }
203  virtual void WritesDone() = 0;
204 
205  virtual void AddHold(int holds) = 0;
206  virtual void RemoveHold() = 0;
207 
208  protected:
210  reactor->BindWriter(this);
211  }
212 };
213 
215  public:
216  virtual ~ClientCallbackUnary() {}
217  virtual void StartCall() = 0;
218 
219  protected:
220  void BindReactor(ClientUnaryReactor* reactor);
221 };
222 
223 // The following classes are the reactor interfaces that are to be implemented
224 // by the user. They are passed in to the library as an argument to a call on a
225 // stub (either a codegen-ed call or a generic call). The streaming RPC is
226 // activated by calling StartCall, possibly after initiating StartRead,
227 // StartWrite, or AddHold operations on the streaming object. Note that none of
228 // the classes are pure; all reactions have a default empty reaction so that the
229 // user class only needs to override those reactions that it cares about.
230 // The reactor must be passed to the stub invocation before any of the below
231 // operations can be called and its reactions will be invoked by the library in
232 // response to the completion of various operations. Reactions must not include
233 // blocking operations (such as blocking I/O, starting synchronous RPCs, or
234 // waiting on condition variables). Reactions may be invoked concurrently,
235 // except that OnDone is called after all others (assuming proper API usage).
236 // The reactor may not be deleted until OnDone is called.
237 
239 template <class Request, class Response>
240 class ClientBidiReactor : public internal::ClientReactor {
241  public:
246  void StartCall() { stream_->StartCall(); }
247 
253  void StartRead(Response* resp) { stream_->Read(resp); }
254 
262 
270  stream_->Write(req, options);
271  }
272 
283  StartWrite(req, options.set_last_message());
284  }
285 
291  void StartWritesDone() { stream_->WritesDone(); }
292 
315  void AddHold() { AddMultipleHolds(1); }
316  void AddMultipleHolds(int holds) {
317  GPR_CODEGEN_DEBUG_ASSERT(holds > 0);
318  stream_->AddHold(holds);
319  }
320  void RemoveHold() { stream_->RemoveHold(); }
321 
329  void OnDone(const grpc::Status& /*s*/) override {}
330 
339  virtual void OnReadInitialMetadataDone(bool /*ok*/) {}
340 
345  virtual void OnReadDone(bool /*ok*/) {}
346 
352  virtual void OnWriteDone(bool /*ok*/) {}
353 
361  virtual void OnWritesDoneDone(bool /*ok*/) {}
362 
363  private:
366  stream_ = stream;
367  }
369 };
370 
373 template <class Response>
375  public:
376  void StartCall() { reader_->StartCall(); }
377  void StartRead(Response* resp) { reader_->Read(resp); }
378 
379  void AddHold() { AddMultipleHolds(1); }
380  void AddMultipleHolds(int holds) {
381  GPR_CODEGEN_DEBUG_ASSERT(holds > 0);
382  reader_->AddHold(holds);
383  }
384  void RemoveHold() { reader_->RemoveHold(); }
385 
386  void OnDone(const grpc::Status& /*s*/) override {}
387  virtual void OnReadInitialMetadataDone(bool /*ok*/) {}
388  virtual void OnReadDone(bool /*ok*/) {}
389 
390  private:
394 };
395 
398 template <class Request>
400  public:
401  void StartCall() { writer_->StartCall(); }
404  writer_->Write(req, options);
405  }
407  StartWrite(req, options.set_last_message());
408  }
409  void StartWritesDone() { writer_->WritesDone(); }
410 
411  void AddHold() { AddMultipleHolds(1); }
412  void AddMultipleHolds(int holds) {
413  GPR_CODEGEN_DEBUG_ASSERT(holds > 0);
414  writer_->AddHold(holds);
415  }
416  void RemoveHold() { writer_->RemoveHold(); }
417 
418  void OnDone(const grpc::Status& /*s*/) override {}
419  virtual void OnReadInitialMetadataDone(bool /*ok*/) {}
420  virtual void OnWriteDone(bool /*ok*/) {}
421  virtual void OnWritesDoneDone(bool /*ok*/) {}
422 
423  private:
426 
428 };
429 
442  public:
443  void StartCall() { call_->StartCall(); }
444  void OnDone(const grpc::Status& /*s*/) override {}
445  virtual void OnReadInitialMetadataDone(bool /*ok*/) {}
446 
447  private:
448  friend class ClientCallbackUnary;
451 };
452 
453 // Define function out-of-line from class to avoid forward declaration issue
455  reactor->BindCall(this);
456 }
457 
458 namespace internal {
459 
460 // Forward declare factory classes for friendship
461 template <class Request, class Response>
462 class ClientCallbackReaderWriterFactory;
463 template <class Response>
464 class ClientCallbackReaderFactory;
465 template <class Request>
466 class ClientCallbackWriterFactory;
467 
468 template <class Request, class Response>
470  : public ClientCallbackReaderWriter<Request, Response> {
471  public:
472  // always allocated against a call arena, no memory free required
473  static void operator delete(void* /*ptr*/, std::size_t size) {
475  }
476 
477  // This operator should never be called as the memory should be freed as part
478  // of the arena destruction. It only exists to provide a matching operator
479  // delete to the operator new so that some compilers will not complain (see
480  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
481  // there are no tests catching the compiler warning.
482  static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); }
483 
485  // This call initiates two batches, plus any backlog, each with a callback
486  // 1. Send initial metadata (unless corked) + recv initial metadata
487  // 2. Any read backlog
488  // 3. Any write backlog
489  // 4. Recv trailing metadata (unless corked)
490  if (!start_corked_) {
491  start_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
493  }
494 
496 
497  {
499 
500  if (backlog_.read_ops) {
502  }
503  if (backlog_.write_ops) {
505  }
506  if (backlog_.writes_done_ops) {
508  }
510  // The last thing in this critical section is to set started_ so that it
511  // can be used lock-free as well.
512  started_.store(true, std::memory_order_release);
513  }
514  // MaybeFinish outside the lock to make sure that destruction of this object
515  // doesn't take place while holding the lock (which would cause the lock to
516  // be released after destruction)
517  this->MaybeFinish(/*from_reaction=*/false);
518  }
519 
520  void Read(Response* msg) override {
521  read_ops_.RecvMessage(msg);
522  callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed);
523  if (GPR_UNLIKELY(!started_.load(std::memory_order_acquire))) {
525  if (GPR_LIKELY(!started_.load(std::memory_order_relaxed))) {
526  backlog_.read_ops = true;
527  return;
528  }
529  }
531  }
532 
534  ABSL_LOCKS_EXCLUDED(start_mu_) override {
535  if (options.is_last_message()) {
536  options.set_buffer_hint();
537  write_ops_.ClientSendClose();
538  }
539  // TODO(vjpai): don't assert
540  GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(msg, options).ok());
541  callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed);
543  write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
545  corked_write_needed_ = false;
546  }
547 
548  if (GPR_UNLIKELY(!started_.load(std::memory_order_acquire))) {
550  if (GPR_LIKELY(!started_.load(std::memory_order_relaxed))) {
551  backlog_.write_ops = true;
552  return;
553  }
554  }
556  }
558  writes_done_ops_.ClientSendClose();
560  call_.call(),
561  [this](bool ok) {
562  reactor_->OnWritesDoneDone(ok);
563  MaybeFinish(/*from_reaction=*/true);
564  },
565  &writes_done_ops_, /*can_inline=*/false);
567  callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed);
569  writes_done_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
571  corked_write_needed_ = false;
572  }
573  if (GPR_UNLIKELY(!started_.load(std::memory_order_acquire))) {
575  if (GPR_LIKELY(!started_.load(std::memory_order_relaxed))) {
576  backlog_.writes_done_ops = true;
577  return;
578  }
579  }
581  }
582 
583  void AddHold(int holds) override {
584  callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed);
585  }
586  void RemoveHold() override { MaybeFinish(/*from_reaction=*/false); }
587 
588  private:
590 
594  : context_(context),
595  call_(call),
596  reactor_(reactor),
597  start_corked_(context_->initial_metadata_corked_),
599  this->BindReactor(reactor);
600 
601  // Set up the unchanging parts of the start, read, and write tags and ops.
602  start_tag_.Set(
603  call_.call(),
604  [this](bool ok) {
605  reactor_->OnReadInitialMetadataDone(
606  ok && !reactor_->InternalTrailersOnly(call_.call()));
607  MaybeFinish(/*from_reaction=*/true);
608  },
609  &start_ops_, /*can_inline=*/false);
610  start_ops_.RecvInitialMetadata(context_);
612 
613  write_tag_.Set(
614  call_.call(),
615  [this](bool ok) {
616  reactor_->OnWriteDone(ok);
617  MaybeFinish(/*from_reaction=*/true);
618  },
619  &write_ops_, /*can_inline=*/false);
621 
622  read_tag_.Set(
623  call_.call(),
624  [this](bool ok) {
625  reactor_->OnReadDone(ok);
626  MaybeFinish(/*from_reaction=*/true);
627  },
628  &read_ops_, /*can_inline=*/false);
630 
631  // Also set up the Finish tag and op set.
633  call_.call(),
634  [this](bool /*ok*/) { MaybeFinish(/*from_reaction=*/true); },
635  &finish_ops_,
636  /*can_inline=*/false);
637  finish_ops_.ClientRecvStatus(context_, &finish_status_);
639  }
640 
641  // MaybeFinish can be called from reactions or from user-initiated operations
642  // like StartCall or RemoveHold. If this is the last operation or hold on this
643  // object, it will invoke the OnDone reaction. If MaybeFinish was called from
644  // a reaction, it can call OnDone directly. If not, it would need to schedule
645  // OnDone onto an executor thread to avoid the possibility of deadlocking with
646  // any locks in the user code that invoked it.
647  void MaybeFinish(bool from_reaction) {
648  if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub(
649  1, std::memory_order_acq_rel) == 1)) {
651  auto* reactor = reactor_;
652  auto* call = call_.call();
655  if (GPR_LIKELY(from_reaction)) {
656  reactor->OnDone(s);
657  } else {
658  reactor->InternalScheduleOnDone(std::move(s));
659  }
660  }
661  }
662 
666 
671  const bool start_corked_;
672  bool corked_write_needed_; // no lock needed since only accessed in
673  // Write/WritesDone which cannot be concurrent
674 
678 
684 
689 
693 
695  bool write_ops = false;
696  bool writes_done_ops = false;
697  bool read_ops = false;
698  };
700 
701  // Minimum of 3 callbacks to pre-register for start ops, StartCall, and finish
702  std::atomic<intptr_t> callbacks_outstanding_{3};
703  std::atomic_bool started_{false};
705 };
706 
707 template <class Request, class Response>
709  public:
715  channel->CreateCall(method, context, channel->CallbackCQ());
716 
721  reactor);
722  }
723 };
724 
725 template <class Response>
727  public:
728  // always allocated against a call arena, no memory free required
729  static void operator delete(void* /*ptr*/, std::size_t size) {
731  }
732 
733  // This operator should never be called as the memory should be freed as part
734  // of the arena destruction. It only exists to provide a matching operator
735  // delete to the operator new so that some compilers will not complain (see
736  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
737  // there are no tests catching the compiler warning.
738  static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); }
739 
740  void StartCall() override {
741  // This call initiates two batches, plus any backlog, each with a callback
742  // 1. Send initial metadata (unless corked) + recv initial metadata
743  // 2. Any backlog
744  // 3. Recv trailing metadata
745 
746  start_tag_.Set(
747  call_.call(),
748  [this](bool ok) {
749  reactor_->OnReadInitialMetadataDone(
750  ok && !reactor_->InternalTrailersOnly(call_.call()));
751  MaybeFinish(/*from_reaction=*/true);
752  },
753  &start_ops_, /*can_inline=*/false);
754  start_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
756  start_ops_.RecvInitialMetadata(context_);
759 
760  // Also set up the read tag so it doesn't have to be set up each time
761  read_tag_.Set(
762  call_.call(),
763  [this](bool ok) {
764  reactor_->OnReadDone(ok);
765  MaybeFinish(/*from_reaction=*/true);
766  },
767  &read_ops_, /*can_inline=*/false);
769 
770  {
772  if (backlog_.read_ops) {
774  }
775  started_.store(true, std::memory_order_release);
776  }
777 
779  call_.call(),
780  [this](bool /*ok*/) { MaybeFinish(/*from_reaction=*/true); },
781  &finish_ops_, /*can_inline=*/false);
782  finish_ops_.ClientRecvStatus(context_, &finish_status_);
785  }
786 
787  void Read(Response* msg) override {
788  read_ops_.RecvMessage(msg);
789  callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed);
790  if (GPR_UNLIKELY(!started_.load(std::memory_order_acquire))) {
792  if (GPR_LIKELY(!started_.load(std::memory_order_relaxed))) {
793  backlog_.read_ops = true;
794  return;
795  }
796  }
798  }
799 
800  void AddHold(int holds) override {
801  callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed);
802  }
803  void RemoveHold() override { MaybeFinish(/*from_reaction=*/false); }
804 
805  private:
807 
808  template <class Request>
812  : context_(context), call_(call), reactor_(reactor) {
813  this->BindReactor(reactor);
814  // TODO(vjpai): don't assert
815  GPR_CODEGEN_ASSERT(start_ops_.SendMessagePtr(request).ok());
816  start_ops_.ClientSendClose();
817  }
818 
819  // MaybeFinish behaves as in ClientCallbackReaderWriterImpl.
820  void MaybeFinish(bool from_reaction) {
821  if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub(
822  1, std::memory_order_acq_rel) == 1)) {
824  auto* reactor = reactor_;
825  auto* call = call_.call();
826  this->~ClientCallbackReaderImpl();
828  if (GPR_LIKELY(from_reaction)) {
829  reactor->OnDone(s);
830  } else {
831  reactor->InternalScheduleOnDone(std::move(s));
832  }
833  }
834  }
835 
839 
846 
850 
854 
856  bool read_ops = false;
857  };
859 
860  // Minimum of 2 callbacks to pre-register for start and finish
861  std::atomic<intptr_t> callbacks_outstanding_{2};
862  std::atomic_bool started_{false};
864 };
865 
866 template <class Response>
868  public:
869  template <class Request>
873  ClientReadReactor<Response>* reactor) {
875  channel->CreateCall(method, context, channel->CallbackCQ());
876 
879  call.call(), sizeof(ClientCallbackReaderImpl<Response>)))
881  }
882 };
883 
884 template <class Request>
886  public:
887  // always allocated against a call arena, no memory free required
888  static void operator delete(void* /*ptr*/, std::size_t size) {
890  }
891 
892  // This operator should never be called as the memory should be freed as part
893  // of the arena destruction. It only exists to provide a matching operator
894  // delete to the operator new so that some compilers will not complain (see
895  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
896  // there are no tests catching the compiler warning.
897  static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); }
898 
900  // This call initiates two batches, plus any backlog, each with a callback
901  // 1. Send initial metadata (unless corked) + recv initial metadata
902  // 2. Any backlog
903  // 3. Recv trailing metadata
904 
905  if (!start_corked_) {
906  start_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
908  }
910 
911  {
913 
914  if (backlog_.write_ops) {
916  }
917  if (backlog_.writes_done_ops) {
919  }
921  // The last thing in this critical section is to set started_ so that it
922  // can be used lock-free as well.
923  started_.store(true, std::memory_order_release);
924  }
925  // MaybeFinish outside the lock to make sure that destruction of this object
926  // doesn't take place while holding the lock (which would cause the lock to
927  // be released after destruction)
928  this->MaybeFinish(/*from_reaction=*/false);
929  }
930 
932  ABSL_LOCKS_EXCLUDED(start_mu_) override {
933  if (GPR_UNLIKELY(options.is_last_message())) {
934  options.set_buffer_hint();
935  write_ops_.ClientSendClose();
936  }
937  // TODO(vjpai): don't assert
938  GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(msg, options).ok());
939  callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed);
940 
942  write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
944  corked_write_needed_ = false;
945  }
946 
947  if (GPR_UNLIKELY(!started_.load(std::memory_order_acquire))) {
949  if (GPR_LIKELY(!started_.load(std::memory_order_relaxed))) {
950  backlog_.write_ops = true;
951  return;
952  }
953  }
955  }
956 
958  writes_done_ops_.ClientSendClose();
960  call_.call(),
961  [this](bool ok) {
962  reactor_->OnWritesDoneDone(ok);
963  MaybeFinish(/*from_reaction=*/true);
964  },
965  &writes_done_ops_, /*can_inline=*/false);
967  callbacks_outstanding_.fetch_add(1, std::memory_order_relaxed);
968 
970  writes_done_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
972  corked_write_needed_ = false;
973  }
974 
975  if (GPR_UNLIKELY(!started_.load(std::memory_order_acquire))) {
977  if (GPR_LIKELY(!started_.load(std::memory_order_relaxed))) {
978  backlog_.writes_done_ops = true;
979  return;
980  }
981  }
983  }
984 
985  void AddHold(int holds) override {
986  callbacks_outstanding_.fetch_add(holds, std::memory_order_relaxed);
987  }
988  void RemoveHold() override { MaybeFinish(/*from_reaction=*/false); }
989 
990  private:
992 
993  template <class Response>
997  : context_(context),
998  call_(call),
999  reactor_(reactor),
1000  start_corked_(context_->initial_metadata_corked_),
1002  this->BindReactor(reactor);
1003 
1004  // Set up the unchanging parts of the start and write tags and ops.
1005  start_tag_.Set(
1006  call_.call(),
1007  [this](bool ok) {
1008  reactor_->OnReadInitialMetadataDone(
1009  ok && !reactor_->InternalTrailersOnly(call_.call()));
1010  MaybeFinish(/*from_reaction=*/true);
1011  },
1012  &start_ops_, /*can_inline=*/false);
1013  start_ops_.RecvInitialMetadata(context_);
1015 
1016  write_tag_.Set(
1017  call_.call(),
1018  [this](bool ok) {
1019  reactor_->OnWriteDone(ok);
1020  MaybeFinish(/*from_reaction=*/true);
1021  },
1022  &write_ops_, /*can_inline=*/false);
1024 
1025  // Also set up the Finish tag and op set.
1026  finish_ops_.RecvMessage(response);
1027  finish_ops_.AllowNoMessage();
1028  finish_tag_.Set(
1029  call_.call(),
1030  [this](bool /*ok*/) { MaybeFinish(/*from_reaction=*/true); },
1031  &finish_ops_,
1032  /*can_inline=*/false);
1033  finish_ops_.ClientRecvStatus(context_, &finish_status_);
1035  }
1036 
1037  // MaybeFinish behaves as in ClientCallbackReaderWriterImpl.
1038  void MaybeFinish(bool from_reaction) {
1039  if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub(
1040  1, std::memory_order_acq_rel) == 1)) {
1042  auto* reactor = reactor_;
1043  auto* call = call_.call();
1044  this->~ClientCallbackWriterImpl();
1046  if (GPR_LIKELY(from_reaction)) {
1047  reactor->OnDone(s);
1048  } else {
1049  reactor->InternalScheduleOnDone(std::move(s));
1050  }
1051  }
1052  }
1053 
1057 
1062  const bool start_corked_;
1063  bool corked_write_needed_; // no lock needed since only accessed in
1064  // Write/WritesDone which cannot be concurrent
1065 
1071 
1077 
1082 
1084  bool write_ops = false;
1085  bool writes_done_ops = false;
1086  };
1088 
1089  // Minimum of 3 callbacks to pre-register for start ops, StartCall, and finish
1090  std::atomic<intptr_t> callbacks_outstanding_{3};
1091  std::atomic_bool started_{false};
1093 };
1094 
1095 template <class Request>
1097  public:
1098  template <class Response>
1102  ClientWriteReactor<Request>* reactor) {
1104  channel->CreateCall(method, context, channel->CallbackCQ());
1105 
1108  call.call(), sizeof(ClientCallbackWriterImpl<Request>)))
1110  }
1111 };
1112 
1114  public:
1115  // always allocated against a call arena, no memory free required
1116  static void operator delete(void* /*ptr*/, std::size_t size) {
1118  }
1119 
1120  // This operator should never be called as the memory should be freed as part
1121  // of the arena destruction. It only exists to provide a matching operator
1122  // delete to the operator new so that some compilers will not complain (see
1123  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
1124  // there are no tests catching the compiler warning.
1125  static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); }
1126 
1127  void StartCall() override {
1128  // This call initiates two batches, each with a callback
1129  // 1. Send initial metadata + write + writes done + recv initial metadata
1130  // 2. Read message, recv trailing metadata
1131 
1132  start_tag_.Set(
1133  call_.call(),
1134  [this](bool ok) {
1135  reactor_->OnReadInitialMetadataDone(
1136  ok && !reactor_->InternalTrailersOnly(call_.call()));
1137  MaybeFinish();
1138  },
1139  &start_ops_, /*can_inline=*/false);
1140  start_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
1142  start_ops_.RecvInitialMetadata(context_);
1145 
1146  finish_tag_.Set(
1147  call_.call(), [this](bool /*ok*/) { MaybeFinish(); }, &finish_ops_,
1148  /*can_inline=*/false);
1149  finish_ops_.ClientRecvStatus(context_, &finish_status_);
1152  }
1153 
1154  private:
1156 
1157  template <class Request, class Response>
1161  : context_(context), call_(call), reactor_(reactor) {
1162  this->BindReactor(reactor);
1163  // TODO(vjpai): don't assert
1164  GPR_CODEGEN_ASSERT(start_ops_.SendMessagePtr(request).ok());
1165  start_ops_.ClientSendClose();
1166  finish_ops_.RecvMessage(response);
1167  finish_ops_.AllowNoMessage();
1168  }
1169 
1170  // In the unary case, MaybeFinish is only ever invoked from a
1171  // library-initiated reaction, so it will just directly call OnDone if this is
1172  // the last reaction for this RPC.
1173  void MaybeFinish() {
1174  if (GPR_UNLIKELY(callbacks_outstanding_.fetch_sub(
1175  1, std::memory_order_acq_rel) == 1)) {
1177  auto* reactor = reactor_;
1178  auto* call = call_.call();
1179  this->~ClientCallbackUnaryImpl();
1181  reactor->OnDone(s);
1182  }
1183  }
1184 
1188 
1195 
1201 
1202  // This call will have 2 callbacks: start and finish
1203  std::atomic<intptr_t> callbacks_outstanding_{2};
1204 };
1205 
1207  public:
1208  template <class Request, class Response, class BaseRequest = Request,
1209  class BaseResponse = Response>
1213  Response* response, ClientUnaryReactor* reactor) {
1215  channel->CreateCall(method, context, channel->CallbackCQ());
1216 
1218 
1220  call.call(), sizeof(ClientCallbackUnaryImpl)))
1222  static_cast<const BaseRequest*>(request),
1223  static_cast<BaseResponse*>(response), reactor);
1224  }
1225 };
1226 
1227 } // namespace internal
1228 } // namespace grpc
1229 #endif // GRPCPP_IMPL_CODEGEN_CLIENT_CALLBACK_H
grpc::internal::ClientReactor
Definition: impl/codegen/client_callback.h:115
grpc::internal::ClientCallbackReaderWriterImpl::start_ops_
grpc::internal::CallOpSet< grpc::internal::CallOpSendInitialMetadata, grpc::internal::CallOpRecvInitialMetadata > start_ops_
Definition: impl/codegen/client_callback.h:669
grpc::ClientContext::send_initial_metadata_
std::multimap< std::string, std::string > send_initial_metadata_
Definition: grpcpp/impl/codegen/client_context.h:502
grpc::internal::ClientCallbackReaderImpl::call_
grpc::internal::Call call_
Definition: impl/codegen/client_callback.h:837
grpc::internal::ClientCallbackWriterImpl::reactor_
ClientWriteReactor< Request > *const reactor_
Definition: impl/codegen/client_callback.h:1056
grpc::internal::ClientCallbackUnaryImpl::callbacks_outstanding_
std::atomic< intptr_t > callbacks_outstanding_
Definition: impl/codegen/client_callback.h:1203
grpc::internal::ClientCallbackReaderWriterImpl::finish_tag_
grpc::internal::CallbackWithSuccessTag finish_tag_
Definition: impl/codegen/client_callback.h:676
grpc::internal::CallbackWithStatusTag
Definition: callback_common.h:71
grpc::ClientUnaryReactor
Definition: impl/codegen/client_callback.h:441
grpc::internal::CallOpSendMessage
Definition: call_op_set.h:289
grpc::internal::ClientCallbackWriterImpl::writes_done_tag_
grpc::internal::CallbackWithSuccessTag writes_done_tag_
Definition: impl/codegen/client_callback.h:1081
grpc::internal::ClientCallbackWriterImpl::write_ops_
grpc::internal::CallOpSet< grpc::internal::CallOpSendInitialMetadata, grpc::internal::CallOpSendMessage, grpc::internal::CallOpClientSendClose > write_ops_
Definition: impl/codegen/client_callback.h:1075
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
grpc::internal::ClientCallbackReaderImpl::finish_tag_
grpc::internal::CallbackWithSuccessTag finish_tag_
Definition: impl/codegen/client_callback.h:848
grpc::ClientReadReactor::reader_
ClientCallbackReader< Response > * reader_
Definition: impl/codegen/client_callback.h:393
grpc::ClientCallbackReaderWriter::AddHold
virtual void AddHold(int holds)=0
grpc::internal::ClientCallbackUnaryFactory::Create
static void Create(grpc::ChannelInterface *channel, const grpc::internal::RpcMethod &method, grpc::ClientContext *context, const Request *request, Response *response, ClientUnaryReactor *reactor)
Definition: impl/codegen/client_callback.h:1210
grpc::internal::ClientCallbackReaderWriterImpl::WritesDone
void WritesDone() ABSL_LOCKS_EXCLUDED(start_mu_) override
Definition: impl/codegen/client_callback.h:557
grpc::ClientUnaryReactor::OnReadInitialMetadataDone
virtual void OnReadInitialMetadataDone(bool)
Definition: impl/codegen/client_callback.h:445
grpc::internal::ClientCallbackReaderWriterImpl::finish_ops_
grpc::internal::CallOpSet< grpc::internal::CallOpClientRecvStatus > finish_ops_
Definition: impl/codegen/client_callback.h:675
grpc::internal::ClientCallbackWriterImpl::finish_ops_
grpc::internal::CallOpSet< grpc::internal::CallOpGenericRecvMessage, grpc::internal::CallOpClientRecvStatus > finish_ops_
Definition: impl/codegen/client_callback.h:1068
grpc::internal::ClientCallbackWriterImpl::start_corked_
const bool start_corked_
Definition: impl/codegen/client_callback.h:1062
grpc::internal::Mutex
Definition: include/grpcpp/impl/codegen/sync.h:59
grpc::ClientUnaryReactor::OnDone
void OnDone(const grpc::Status &) override
Definition: impl/codegen/client_callback.h:444
grpc::ClientCallbackWriter::RemoveHold
virtual void RemoveHold()=0
grpc
Definition: grpcpp/alarm.h:33
grpc::internal::ClientCallbackUnaryImpl::StartCall
void StartCall() override
Definition: impl/codegen/client_callback.h:1127
grpc::ClientCallbackReaderWriter::WritesDone
virtual void WritesDone()=0
grpc::internal::ClientCallbackReaderImpl::read_tag_
grpc::internal::CallbackWithSuccessTag read_tag_
Definition: impl/codegen/client_callback.h:853
grpc::internal::ClientCallbackReaderWriterImpl::call_
grpc::internal::Call call_
Definition: impl/codegen/client_callback.h:664
grpc::ClientBidiReactor::StartCall
void StartCall()
Definition: impl/codegen/client_callback.h:246
grpc::internal::Call::call
grpc_call * call() const
Definition: include/grpcpp/impl/codegen/call.h:71
grpc::internal::ClientCallbackWriterImpl
Definition: impl/codegen/client_callback.h:885
grpc::ClientBidiReactor
ClientBidiReactor is the interface for a bidirectional streaming RPC.
Definition: impl/codegen/client_callback.h:151
grpc::internal::ClientCallbackReaderWriterFactory
Definition: grpcpp/impl/codegen/channel_interface.h:47
grpc::ClientBidiReactor::OnDone
void OnDone(const grpc::Status &) override
Definition: impl/codegen/client_callback.h:329
grpc::ClientWriteReactor::writer_
ClientCallbackWriter< Request > * writer_
Definition: impl/codegen/client_callback.h:427
GPR_LIKELY
#define GPR_LIKELY(x)
Definition: impl/codegen/port_platform.h:769
options
double_dict options[]
Definition: capstone_test.c:55
grpc::ClientReadReactor::RemoveHold
void RemoveHold()
Definition: impl/codegen/client_callback.h:384
benchmark.request
request
Definition: benchmark.py:77
grpc::internal::CallOpGenericRecvMessage
Definition: call_op_set.h:533
grpc::internal::ClientCallbackReaderWriterImpl::start_corked_
const bool start_corked_
Definition: impl/codegen/client_callback.h:671
grpc::internal::ClientCallbackReaderWriterFactory::Create
static void Create(grpc::ChannelInterface *channel, const grpc::internal::RpcMethod &method, grpc::ClientContext *context, ClientBidiReactor< Request, Response > *reactor)
Definition: impl/codegen/client_callback.h:710
grpc::internal::CallbackUnaryCallImpl::CallbackUnaryCallImpl
CallbackUnaryCallImpl(grpc::ChannelInterface *channel, const grpc::internal::RpcMethod &method, grpc::ClientContext *context, const InputMessage *request, OutputMessage *result, std::function< void(grpc::Status)> on_completion)
Definition: impl/codegen/client_callback.h:67
grpc::internal::ClientCallbackWriterImpl::Write
void Write(const Request *msg, grpc::WriteOptions options) ABSL_LOCKS_EXCLUDED(start_mu_) override
Definition: impl/codegen/client_callback.h:931
grpc::ClientWriteReactor::StartWrite
void StartWrite(const Request *req)
Definition: impl/codegen/client_callback.h:402
grpc::internal::ClientCallbackReaderWriterImpl::MaybeFinish
void MaybeFinish(bool from_reaction)
Definition: impl/codegen/client_callback.h:647
grpc::internal::ClientCallbackReaderImpl::read_ops_
grpc::internal::CallOpSet< grpc::internal::CallOpRecvMessage< Response > > read_ops_
Definition: impl/codegen/client_callback.h:852
grpc::internal::ClientCallbackWriterFactory
Definition: grpcpp/impl/codegen/channel_interface.h:51
grpc::internal::CallbackUnaryCallImpl
Definition: grpcpp/impl/codegen/channel_interface.h:38
grpc::internal::CallbackUnaryCall
void CallbackUnaryCall(grpc::ChannelInterface *channel, const grpc::internal::RpcMethod &method, grpc::ClientContext *context, const InputMessage *request, OutputMessage *result, std::function< void(grpc::Status)> on_completion)
Definition: impl/codegen/client_callback.h:51
grpc::internal::CallOpSet::set_core_cq_tag
void set_core_cq_tag(void *core_cq_tag)
Definition: call_op_set.h:951
grpc::ClientWriteReactor::AddHold
void AddHold()
Definition: impl/codegen/client_callback.h:411
grpc::internal::ClientCallbackWriterImpl::ABSL_GUARDED_BY
StartCallBacklog backlog_ ABSL_GUARDED_BY(start_mu_)
grpc::CoreCodegenInterface::grpc_call_arena_alloc
virtual void * grpc_call_arena_alloc(grpc_call *call, size_t length)=0
grpc::ClientReadReactor
Definition: impl/codegen/client_callback.h:153
grpc::ClientBidiReactor::StartWrite
void StartWrite(const Request *req)
Definition: impl/codegen/client_callback.h:261
core_codegen_interface.h
grpc::ClientCallbackUnary::StartCall
virtual void StartCall()=0
grpc::ClientCallbackReaderWriter::~ClientCallbackReaderWriter
virtual ~ClientCallbackReaderWriter()
Definition: impl/codegen/client_callback.h:164
grpc::internal::ClientCallbackReaderWriterImpl::started_
std::atomic_bool started_
Definition: impl/codegen/client_callback.h:703
grpc::internal::ClientCallbackReaderWriterImpl::AddHold
void AddHold(int holds) override
Definition: impl/codegen/client_callback.h:583
grpc::internal::ClientCallbackReaderWriterImpl::RemoveHold
void RemoveHold() override
Definition: impl/codegen/client_callback.h:586
grpc::internal::ClientCallbackReaderImpl::start_mu_
grpc::internal::Mutex start_mu_
Definition: impl/codegen/client_callback.h:863
grpc::ClientBidiReactor::OnReadDone
virtual void OnReadDone(bool)
Definition: impl/codegen/client_callback.h:345
grpc::internal::ClientCallbackReaderWriterImpl::StartCallBacklog::read_ops
bool read_ops
Definition: impl/codegen/client_callback.h:697
grpc::ClientCallbackWriter::WriteLast
void WriteLast(const Request *req, grpc::WriteOptions options)
Definition: impl/codegen/client_callback.h:200
grpc::ClientCallbackReaderWriter::Read
virtual void Read(Response *resp)=0
grpc::ClientCallbackUnary::BindReactor
void BindReactor(ClientUnaryReactor *reactor)
Definition: impl/codegen/client_callback.h:454
grpc::ClientWriteReactor::OnDone
void OnDone(const grpc::Status &) override
Definition: impl/codegen/client_callback.h:418
grpc::ClientCallbackReader::RemoveHold
virtual void RemoveHold()=0
grpc::ClientWriteReactor::RemoveHold
void RemoveHold()
Definition: impl/codegen/client_callback.h:416
grpc::internal::ClientReactor::~ClientReactor
virtual ~ClientReactor()=default
grpc::ClientReadReactor::OnReadDone
virtual void OnReadDone(bool)
Definition: impl/codegen/client_callback.h:388
grpc::internal::MutexLock
Definition: include/grpcpp/impl/codegen/sync.h:86
grpc::ClientCallbackReader::~ClientCallbackReader
virtual ~ClientCallbackReader()
Definition: impl/codegen/client_callback.h:181
grpc::ClientCallbackReaderWriter::StartCall
virtual void StartCall()=0
grpc::ClientCallbackWriter::Write
void Write(const Request *req)
Definition: impl/codegen/client_callback.h:198
config.h
call
FilterStackCall * call
Definition: call.cc:750
grpc::internal::ClientReactor::OnDone
virtual void OnDone(const grpc::Status &)=0
grpc::ClientBidiReactor::BindStream
void BindStream(ClientCallbackReaderWriter< Request, Response > *stream)
Definition: impl/codegen/client_callback.h:365
grpc::WriteOptions
Per-message write options.
Definition: call_op_set.h:81
grpc::internal::ClientCallbackReaderImpl::StartCallBacklog
Definition: impl/codegen/client_callback.h:855
grpc::internal::ClientCallbackReaderImpl::started_
std::atomic_bool started_
Definition: impl/codegen/client_callback.h:862
grpc::internal::ClientCallbackReaderWriterImpl::write_tag_
grpc::internal::CallbackWithSuccessTag write_tag_
Definition: impl/codegen/client_callback.h:683
grpc::internal::ClientCallbackReaderFactory::Create
static void Create(grpc::ChannelInterface *channel, const grpc::internal::RpcMethod &method, grpc::ClientContext *context, const Request *request, ClientReadReactor< Response > *reactor)
Definition: impl/codegen/client_callback.h:870
grpc::ClientReadReactor::OnReadInitialMetadataDone
virtual void OnReadInitialMetadataDone(bool)
Definition: impl/codegen/client_callback.h:387
grpc::ClientWriteReactor::StartCall
void StartCall()
Definition: impl/codegen/client_callback.h:401
grpc::internal::CallOpClientRecvStatus
Definition: call_op_set.h:776
grpc::g_core_codegen_interface
CoreCodegenInterface * g_core_codegen_interface
Definition: include/grpcpp/impl/codegen/completion_queue.h:98
grpc::internal::ClientCallbackWriterImpl::finish_status_
grpc::Status finish_status_
Definition: impl/codegen/client_callback.h:1070
framework.rpc.grpc_channelz.Channel
Channel
Definition: grpc_channelz.py:32
grpc::internal::ClientCallbackReaderImpl::ClientCallbackReaderImpl
ClientCallbackReaderImpl(grpc::internal::Call call, grpc::ClientContext *context, Request *request, ClientReadReactor< Response > *reactor)
Definition: impl/codegen/client_callback.h:809
grpc::ChannelInterface
Codegen interface for grpc::Channel.
Definition: grpcpp/impl/codegen/channel_interface.h:73
grpc::ClientReadReactor::StartCall
void StartCall()
Definition: impl/codegen/client_callback.h:376
channel
wrapped_grpc_channel * channel
Definition: src/php/ext/grpc/call.h:33
grpc::ClientBidiReactor::stream_
ClientCallbackReaderWriter< Request, Response > * stream_
Definition: impl/codegen/client_callback.h:368
sync.h
grpc::ClientCallbackUnary
Definition: impl/codegen/client_callback.h:214
grpc::internal::ClientCallbackWriterFactory::Create
static void Create(grpc::ChannelInterface *channel, const grpc::internal::RpcMethod &method, grpc::ClientContext *context, Response *response, ClientWriteReactor< Request > *reactor)
Definition: impl/codegen/client_callback.h:1099
grpc::internal::ClientCallbackWriterImpl::started_
std::atomic_bool started_
Definition: impl/codegen/client_callback.h:1091
grpc::ClientBidiReactor::AddHold
void AddHold()
Definition: impl/codegen/client_callback.h:315
grpc::ClientBidiReactor::StartWrite
void StartWrite(const Request *req, grpc::WriteOptions options)
Definition: impl/codegen/client_callback.h:269
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
grpc::internal::ClientCallbackUnaryImpl::start_ops_
grpc::internal::CallOpSet< grpc::internal::CallOpSendInitialMetadata, grpc::internal::CallOpSendMessage, grpc::internal::CallOpClientSendClose, grpc::internal::CallOpRecvInitialMetadata > start_ops_
Definition: impl/codegen/client_callback.h:1193
grpc::internal::RpcMethod
Descriptor of an RPC method.
Definition: grpcpp/impl/codegen/rpc_method.h:31
grpc::ClientWriteReactor::StartWriteLast
void StartWriteLast(const Request *req, grpc::WriteOptions options)
Definition: impl/codegen/client_callback.h:406
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
grpc::ClientWriteReactor
Definition: impl/codegen/client_callback.h:155
grpc::internal::ClientCallbackUnaryImpl::MaybeFinish
void MaybeFinish()
Definition: impl/codegen/client_callback.h:1173
grpc::internal::ClientCallbackReaderWriterImpl::Read
void Read(Response *msg) override
Definition: impl/codegen/client_callback.h:520
grpc::internal::ClientCallbackReaderWriterImpl::StartCallBacklog::write_ops
bool write_ops
Definition: impl/codegen/client_callback.h:695
grpc::ClientCallbackReader::Read
virtual void Read(Response *resp)=0
grpc::internal::ClientCallbackWriterImpl::WritesDone
void WritesDone() ABSL_LOCKS_EXCLUDED(start_mu_) override
Definition: impl/codegen/client_callback.h:957
grpc::internal::CallbackWithSuccessTag
Definition: callback_common.h:137
req
static uv_connect_t req
Definition: test-connection-fail.c:30
grpc::ClientBidiReactor::OnWriteDone
virtual void OnWriteDone(bool)
Definition: impl/codegen/client_callback.h:352
grpc::internal::ClientCallbackReaderWriterImpl::writes_done_tag_
grpc::internal::CallbackWithSuccessTag writes_done_tag_
Definition: impl/codegen/client_callback.h:688
http2_server_health_check.resp
resp
Definition: http2_server_health_check.py:31
grpc::ClientBidiReactor::StartWritesDone
void StartWritesDone()
Definition: impl/codegen/client_callback.h:291
grpc::ClientCallbackWriter::~ClientCallbackWriter
virtual ~ClientCallbackWriter()
Definition: impl/codegen/client_callback.h:196
grpc::ClientCallbackUnary::~ClientCallbackUnary
virtual ~ClientCallbackUnary()
Definition: impl/codegen/client_callback.h:216
GPR_UNLIKELY
#define GPR_UNLIKELY(x)
Definition: impl/codegen/port_platform.h:770
grpc::internal::ClientCallbackWriterImpl::StartCallBacklog
Definition: impl/codegen/client_callback.h:1083
grpc::internal::ClientCallbackUnaryImpl
Definition: impl/codegen/client_callback.h:1113
grpc_call
struct grpc_call grpc_call
Definition: grpc_types.h:70
grpc::ClientUnaryReactor::call_
ClientCallbackUnary * call_
Definition: impl/codegen/client_callback.h:450
grpc::internal::Call::PerformOps
void PerformOps(CallOpSetInterface *ops)
Definition: include/grpcpp/impl/codegen/call.h:67
grpc::ClientWriteReactor::StartWrite
void StartWrite(const Request *req, grpc::WriteOptions options)
Definition: impl/codegen/client_callback.h:403
grpc::internal::ClientCallbackReaderWriterImpl::callbacks_outstanding_
std::atomic< intptr_t > callbacks_outstanding_
Definition: impl/codegen/client_callback.h:702
grpc::internal::ClientCallbackReaderImpl::AddHold
void AddHold(int holds) override
Definition: impl/codegen/client_callback.h:800
grpc::ClientCallbackWriter::BindReactor
void BindReactor(ClientWriteReactor< Request > *reactor)
Definition: impl/codegen/client_callback.h:209
grpc::ClientCallbackReaderWriter
Definition: impl/codegen/client_callback.h:162
grpc::internal::ClientCallbackWriterImpl::call_
grpc::internal::Call call_
Definition: impl/codegen/client_callback.h:1055
grpc::internal::ClientCallbackReaderWriterImpl::start_tag_
grpc::internal::CallbackWithSuccessTag start_tag_
Definition: impl/codegen/client_callback.h:670
grpc::ClientWriteReactor::OnWriteDone
virtual void OnWriteDone(bool)
Definition: impl/codegen/client_callback.h:420
grpc::internal::ClientCallbackUnaryImpl::context_
grpc::ClientContext *const context_
Definition: impl/codegen/client_callback.h:1185
grpc::internal::ClientCallbackUnaryImpl::call_
grpc::internal::Call call_
Definition: impl/codegen/client_callback.h:1186
grpc::ClientBidiReactor::RemoveHold
void RemoveHold()
Definition: impl/codegen/client_callback.h:320
grpc::ClientBidiReactor::OnWritesDoneDone
virtual void OnWritesDoneDone(bool)
Definition: impl/codegen/client_callback.h:361
grpc::ClientReadReactor::StartRead
void StartRead(Response *resp)
Definition: impl/codegen/client_callback.h:377
x
int x
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3610
grpc::ClientWriteReactor::StartWritesDone
void StartWritesDone()
Definition: impl/codegen/client_callback.h:409
grpc::internal::ClientCallbackWriterImpl::StartCall
void StartCall() ABSL_LOCKS_EXCLUDED(start_mu_) override
Definition: impl/codegen/client_callback.h:899
grpc::internal::ClientCallbackReaderImpl::RemoveHold
void RemoveHold() override
Definition: impl/codegen/client_callback.h:803
grpc::internal::ClientCallbackReaderImpl::reactor_
ClientReadReactor< Response > *const reactor_
Definition: impl/codegen/client_callback.h:838
grpc::internal::ClientCallbackWriterImpl::context_
grpc::ClientContext *const context_
Definition: impl/codegen/client_callback.h:1054
grpc::internal::ClientCallbackReaderWriterImpl::context_
grpc::ClientContext *const context_
Definition: impl/codegen/client_callback.h:663
grpc::internal::CallOpRecvMessage
Definition: include/grpcpp/impl/codegen/byte_buffer.h:52
grpc::internal::ClientCallbackWriterImpl::StartCallBacklog::write_ops
bool write_ops
Definition: impl/codegen/client_callback.h:1084
grpc::ClientBidiReactor::OnReadInitialMetadataDone
virtual void OnReadInitialMetadataDone(bool)
Definition: impl/codegen/client_callback.h:339
grpc::internal::ClientCallbackReaderImpl::start_ops_
grpc::internal::CallOpSet< grpc::internal::CallOpSendInitialMetadata, grpc::internal::CallOpSendMessage, grpc::internal::CallOpClientSendClose, grpc::internal::CallOpRecvInitialMetadata > start_ops_
Definition: impl/codegen/client_callback.h:844
grpc::internal::Call
Straightforward wrapping of the C call object.
Definition: include/grpcpp/impl/codegen/call.h:37
grpc::internal::CallOpSet
Definition: call_op_set.h:859
msg
std::string msg
Definition: client_interceptors_end2end_test.cc:372
grpc::ClientCallbackReaderWriter::RemoveHold
virtual void RemoveHold()=0
grpc::internal::CallOpRecvInitialMetadata
Definition: call_op_set.h:728
grpc::internal::ClientCallbackReaderImpl::StartCallBacklog::read_ops
bool read_ops
Definition: impl/codegen/client_callback.h:856
grpc::ClientContext::initial_metadata_flags
uint32_t initial_metadata_flags() const
Definition: grpcpp/impl/codegen/client_context.h:474
grpc::internal::ClientCallbackReaderImpl::finish_status_
grpc::Status finish_status_
Definition: impl/codegen/client_callback.h:849
grpc::internal::ClientCallbackUnaryImpl::finish_tag_
grpc::internal::CallbackWithSuccessTag finish_tag_
Definition: impl/codegen/client_callback.h:1199
grpc::ClientBidiReactor::StartRead
void StartRead(Response *resp)
Definition: impl/codegen/client_callback.h:253
grpc::internal::ClientCallbackReaderImpl::callbacks_outstanding_
std::atomic< intptr_t > callbacks_outstanding_
Definition: impl/codegen/client_callback.h:861
writer
void writer(void *n)
Definition: libuv/docs/code/locks/main.c:22
grpc::ClientContext
Definition: grpcpp/impl/codegen/client_context.h:195
grpc::internal::ClientCallbackWriterImpl::AddHold
void AddHold(int holds) override
Definition: impl/codegen/client_callback.h:985
value
const char * value
Definition: hpack_parser_table.cc:165
grpc::internal::ClientCallbackWriterImpl::corked_write_needed_
bool corked_write_needed_
Definition: impl/codegen/client_callback.h:1063
grpc::internal::ClientCallbackUnaryImpl::start_tag_
grpc::internal::CallbackWithSuccessTag start_tag_
Definition: impl/codegen/client_callback.h:1194
grpc::internal::ClientCallbackWriterImpl::finish_tag_
grpc::internal::CallbackWithSuccessTag finish_tag_
Definition: impl/codegen/client_callback.h:1069
grpc::internal::ClientCallbackReaderImpl
Definition: impl/codegen/client_callback.h:726
grpc::internal::ClientCallbackReaderWriterImpl::writes_done_ops_
grpc::internal::CallOpSet< grpc::internal::CallOpSendInitialMetadata, grpc::internal::CallOpClientSendClose > writes_done_ops_
Definition: impl/codegen/client_callback.h:687
grpc::ClientBidiReactor::StartWriteLast
void StartWriteLast(const Request *req, grpc::WriteOptions options)
Definition: impl/codegen/client_callback.h:282
grpc::internal::ClientCallbackUnaryFactory
Definition: impl/codegen/client_callback.h:1206
status.h
grpc::ClientWriteReactor::OnWritesDoneDone
virtual void OnWritesDoneDone(bool)
Definition: impl/codegen/client_callback.h:421
grpc::ClientCallbackReader::StartCall
virtual void StartCall()=0
grpc::ClientCallbackReader::AddHold
virtual void AddHold(int holds)=0
callback_common.h
grpc::ClientReadReactor::AddHold
void AddHold()
Definition: impl/codegen/client_callback.h:379
grpc::internal::CallOpSendInitialMetadata
Definition: call_op_set.h:219
grpc::ClientWriteReactor::AddMultipleHolds
void AddMultipleHolds(int holds)
Definition: impl/codegen/client_callback.h:412
channel_interface.h
grpc::ClientCallbackWriter::AddHold
virtual void AddHold(int holds)=0
grpc::ClientCallbackReaderWriter::BindReactor
void BindReactor(ClientBidiReactor< Request, Response > *reactor)
Definition: impl/codegen/client_callback.h:173
grpc::internal::ClientCallbackReaderFactory
Definition: grpcpp/impl/codegen/channel_interface.h:49
ABSL_LOCKS_EXCLUDED
#define ABSL_LOCKS_EXCLUDED(...)
Definition: abseil-cpp/absl/base/thread_annotations.h:163
grpc::ClientCallbackWriter::StartCall
virtual void StartCall()=0
grpc::internal::ClientCallbackUnaryImpl::finish_ops_
grpc::internal::CallOpSet< grpc::internal::CallOpGenericRecvMessage, grpc::internal::CallOpClientRecvStatus > finish_ops_
Definition: impl/codegen/client_callback.h:1198
grpc::internal::CallbackWithSuccessTag::Set
void Set(grpc_call *call, std::function< void(bool)> f, CompletionQueueTag *ops, bool can_inline)
Definition: callback_common.h:164
grpc::internal::ClientCallbackWriterImpl::MaybeFinish
void MaybeFinish(bool from_reaction)
Definition: impl/codegen/client_callback.h:1038
grpc::internal::ClientCallbackReaderWriterImpl::corked_write_needed_
bool corked_write_needed_
Definition: impl/codegen/client_callback.h:672
grpc::internal::ClientCallbackReaderWriterImpl
Definition: impl/codegen/client_callback.h:469
grpc::internal::ClientCallbackReaderImpl::start_tag_
grpc::internal::CallbackWithSuccessTag start_tag_
Definition: impl/codegen/client_callback.h:845
grpc::internal::ClientCallbackWriterImpl::start_mu_
grpc::internal::Mutex start_mu_
Definition: impl/codegen/client_callback.h:1092
grpc::ClientWriteReactor::OnReadInitialMetadataDone
virtual void OnReadInitialMetadataDone(bool)
Definition: impl/codegen/client_callback.h:419
grpc::ClientReadReactor::OnDone
void OnDone(const grpc::Status &) override
Definition: impl/codegen/client_callback.h:386
asyncio_get_stats.response
response
Definition: asyncio_get_stats.py:28
call_op_set.h
grpc::internal::ClientCallbackWriterImpl::StartCallBacklog::writes_done_ops
bool writes_done_ops
Definition: impl/codegen/client_callback.h:1085
grpc::internal::ClientCallbackReaderWriterImpl::write_ops_
grpc::internal::CallOpSet< grpc::internal::CallOpSendInitialMetadata, grpc::internal::CallOpSendMessage, grpc::internal::CallOpClientSendClose > write_ops_
Definition: impl/codegen/client_callback.h:682
grpc::internal::ClientCallbackReaderImpl::ABSL_GUARDED_BY
StartCallBacklog backlog_ ABSL_GUARDED_BY(start_mu_)
grpc::internal::ClientReactor::InternalTrailersOnly
virtual bool InternalTrailersOnly(const grpc_call *call) const
Definition: src/cpp/client/client_callback.cc:57
grpc::internal::ClientCallbackWriterImpl::start_tag_
grpc::internal::CallbackWithSuccessTag start_tag_
Definition: impl/codegen/client_callback.h:1061
grpc::Status
Definition: include/grpcpp/impl/codegen/status.h:35
ok
bool ok
Definition: async_end2end_test.cc:197
grpc::internal::ClientCallbackReaderImpl::MaybeFinish
void MaybeFinish(bool from_reaction)
Definition: impl/codegen/client_callback.h:820
grpc::internal::ClientCallbackWriterImpl::writes_done_ops_
grpc::internal::CallOpSet< grpc::internal::CallOpSendInitialMetadata, grpc::internal::CallOpClientSendClose > writes_done_ops_
Definition: impl/codegen/client_callback.h:1080
grpc::internal::ClientCallbackReaderWriterImpl::Write
void Write(const Request *msg, grpc::WriteOptions options) ABSL_LOCKS_EXCLUDED(start_mu_) override
Definition: impl/codegen/client_callback.h:533
grpc::internal::ClientReactor::InternalScheduleOnDone
virtual void InternalScheduleOnDone(grpc::Status s)
Definition: src/cpp/client/client_callback.cc:33
grpc::ClientUnaryReactor::StartCall
void StartCall()
Definition: impl/codegen/client_callback.h:443
grpc::internal::CallOpClientSendClose
Definition: call_op_set.h:626
grpc::ClientWriteReactor::BindWriter
void BindWriter(ClientCallbackWriter< Request > *writer)
Definition: impl/codegen/client_callback.h:425
grpc::internal::ClientCallbackUnaryImpl::ClientCallbackUnaryImpl
ClientCallbackUnaryImpl(grpc::internal::Call call, grpc::ClientContext *context, Request *request, Response *response, ClientUnaryReactor *reactor)
Definition: impl/codegen/client_callback.h:1158
grpc::internal::ClientCallbackReaderImpl::context_
grpc::ClientContext *const context_
Definition: impl/codegen/client_callback.h:836
grpc::CoreCodegenInterface::grpc_call_ref
virtual void grpc_call_ref(grpc_call *call)=0
grpc::internal::ClientCallbackWriterImpl::write_tag_
grpc::internal::CallbackWithSuccessTag write_tag_
Definition: impl/codegen/client_callback.h:1076
grpc::internal::ClientCallbackReaderWriterImpl::finish_status_
grpc::Status finish_status_
Definition: impl/codegen/client_callback.h:677
grpc::ClientBidiReactor::AddMultipleHolds
void AddMultipleHolds(int holds)
Definition: impl/codegen/client_callback.h:316
GPR_CODEGEN_ASSERT
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: grpcpp/impl/codegen/core_codegen_interface.h:151
grpc::internal::ClientCallbackReaderWriterImpl::read_tag_
grpc::internal::CallbackWithSuccessTag read_tag_
Definition: impl/codegen/client_callback.h:692
demo_pb2.Request
Request
Definition: demo_pb2.py:108
internal
Definition: benchmark/test/output_test_helper.cc:20
grpc::internal::ClientCallbackReaderWriterImpl::StartCallBacklog
Definition: impl/codegen/client_callback.h:694
grpc::ClientCallbackWriter::WritesDone
virtual void WritesDone()=0
context
grpc::ClientContext context
Definition: istio_echo_server_lib.cc:61
grpc::internal::ClientCallbackWriterImpl::ClientCallbackWriterImpl
ClientCallbackWriterImpl(grpc::internal::Call call, grpc::ClientContext *context, Response *response, ClientWriteReactor< Request > *reactor)
Definition: impl/codegen/client_callback.h:994
grpc::internal::ClientCallbackUnaryImpl::finish_status_
grpc::Status finish_status_
Definition: impl/codegen/client_callback.h:1200
grpc::internal::ClientCallbackReaderImpl::finish_ops_
grpc::internal::CallOpSet< grpc::internal::CallOpClientRecvStatus > finish_ops_
Definition: impl/codegen/client_callback.h:847
grpc::internal::ClientCallbackReaderImpl::StartCall
void StartCall() override
Definition: impl/codegen/client_callback.h:740
grpc::CompletionQueue
Definition: include/grpcpp/impl/codegen/completion_queue.h:104
grpc::internal::ClientCallbackReaderWriterImpl::reactor_
ClientBidiReactor< Request, Response > *const reactor_
Definition: impl/codegen/client_callback.h:665
grpc::internal::ClientCallbackWriterImpl::start_ops_
grpc::internal::CallOpSet< grpc::internal::CallOpSendInitialMetadata, grpc::internal::CallOpRecvInitialMetadata > start_ops_
Definition: impl/codegen/client_callback.h:1060
function
std::function< bool(GrpcTool *, int, const char **, const CliCredentials &, GrpcToolOutputCallback)> function
Definition: grpc_tool.cc:250
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
grpc::internal::ClientCallbackUnaryImpl::reactor_
ClientUnaryReactor *const reactor_
Definition: impl/codegen/client_callback.h:1187
grpc::ClientReadReactor::BindReader
void BindReader(ClientCallbackReader< Response > *reader)
Definition: impl/codegen/client_callback.h:392
method
NSString * method
Definition: ProtoMethod.h:28
grpc::internal::ClientCallbackReaderWriterImpl::StartCall
void StartCall() ABSL_LOCKS_EXCLUDED(start_mu_) override
Definition: impl/codegen/client_callback.h:484
grpc::internal::ClientCallbackReaderWriterImpl::start_mu_
grpc::internal::Mutex start_mu_
Definition: impl/codegen/client_callback.h:704
grpc::ClientCallbackWriter
Definition: impl/codegen/client_callback.h:194
grpc::internal::ClientCallbackReaderWriterImpl::StartCallBacklog::writes_done_ops
bool writes_done_ops
Definition: impl/codegen/client_callback.h:696
demo_pb2.Response
Response
Definition: demo_pb2.py:115
grpc::internal::ClientCallbackReaderWriterImpl::ABSL_GUARDED_BY
StartCallBacklog backlog_ ABSL_GUARDED_BY(start_mu_)
ops
static grpc_op ops[6]
Definition: test/core/fling/client.cc:39
grpc::ClientUnaryReactor::BindCall
void BindCall(ClientCallbackUnary *call)
Definition: impl/codegen/client_callback.h:449
grpc::internal::ClientCallbackWriterImpl::callbacks_outstanding_
std::atomic< intptr_t > callbacks_outstanding_
Definition: impl/codegen/client_callback.h:1090
grpc::ClientCallbackReaderWriter::Write
virtual void Write(const Request *req, grpc::WriteOptions options)=0
grpc::CoreCodegenInterface::grpc_call_unref
virtual void grpc_call_unref(grpc_call *call)=0
cq
static grpc_completion_queue * cq
Definition: test/core/fling/client.cc:37
grpc::internal::ClientCallbackReaderWriterImpl::ClientCallbackReaderWriterImpl
ClientCallbackReaderWriterImpl(grpc::internal::Call call, grpc::ClientContext *context, ClientBidiReactor< Request, Response > *reactor)
Definition: impl/codegen/client_callback.h:591
reader
void reader(void *n)
Definition: libuv/docs/code/locks/main.c:8
grpc::internal::ClientCallbackWriterImpl::RemoveHold
void RemoveHold() override
Definition: impl/codegen/client_callback.h:988
grpc::ClientReadReactor::AddMultipleHolds
void AddMultipleHolds(int holds)
Definition: impl/codegen/client_callback.h:380
grpc::ClientCallbackReader
Definition: impl/codegen/client_callback.h:179
grpc::internal::ClientCallbackReaderImpl::Read
void Read(Response *msg) override
Definition: impl/codegen/client_callback.h:787
grpc::internal::ClientCallbackReaderWriterImpl::read_ops_
grpc::internal::CallOpSet< grpc::internal::CallOpRecvMessage< Response > > read_ops_
Definition: impl/codegen/client_callback.h:691
GPR_CODEGEN_DEBUG_ASSERT
#define GPR_CODEGEN_DEBUG_ASSERT(x)
Codegen specific version of GPR_DEBUG_ASSERT.
Definition: grpcpp/impl/codegen/core_codegen_interface.h:160
grpc::ClientCallbackReader::BindReactor
void BindReactor(ClientReadReactor< Response > *reactor)
Definition: impl/codegen/client_callback.h:188
call.h
stream
voidpf stream
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:46