You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

call.h 3.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. *
  3. * Copyright 2018 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_CALL_H
  19. #define GRPCPP_IMPL_CODEGEN_CALL_H
  20. // IWYU pragma: private, include <grpcpp/impl/call.h>
  21. #include <grpc/impl/codegen/grpc_types.h>
  22. #include <grpcpp/impl/codegen/call_hook.h>
  23. namespace grpc
  24. {
  25. class CompletionQueue;
  26. namespace experimental
  27. {
  28. class ClientRpcInfo;
  29. class ServerRpcInfo;
  30. } // namespace experimental
  31. namespace internal
  32. {
  33. class CallHook;
  34. class CallOpSetInterface;
  35. /// Straightforward wrapping of the C call object
  36. class Call final
  37. {
  38. public:
  39. Call() :
  40. call_hook_(nullptr),
  41. cq_(nullptr),
  42. call_(nullptr),
  43. max_receive_message_size_(-1)
  44. {
  45. }
  46. /** call is owned by the caller */
  47. Call(grpc_call* call, CallHook* call_hook, grpc::CompletionQueue* cq) :
  48. call_hook_(call_hook),
  49. cq_(cq),
  50. call_(call),
  51. max_receive_message_size_(-1)
  52. {
  53. }
  54. Call(grpc_call* call, CallHook* call_hook, grpc::CompletionQueue* cq, experimental::ClientRpcInfo* rpc_info) :
  55. call_hook_(call_hook),
  56. cq_(cq),
  57. call_(call),
  58. max_receive_message_size_(-1),
  59. client_rpc_info_(rpc_info)
  60. {
  61. }
  62. Call(grpc_call* call, CallHook* call_hook, grpc::CompletionQueue* cq, int max_receive_message_size, experimental::ServerRpcInfo* rpc_info) :
  63. call_hook_(call_hook),
  64. cq_(cq),
  65. call_(call),
  66. max_receive_message_size_(max_receive_message_size),
  67. server_rpc_info_(rpc_info)
  68. {
  69. }
  70. void PerformOps(CallOpSetInterface* ops)
  71. {
  72. call_hook_->PerformOpsOnCall(ops, this);
  73. }
  74. grpc_call* call() const
  75. {
  76. return call_;
  77. }
  78. grpc::CompletionQueue* cq() const
  79. {
  80. return cq_;
  81. }
  82. int max_receive_message_size() const
  83. {
  84. return max_receive_message_size_;
  85. }
  86. experimental::ClientRpcInfo* client_rpc_info() const
  87. {
  88. return client_rpc_info_;
  89. }
  90. experimental::ServerRpcInfo* server_rpc_info() const
  91. {
  92. return server_rpc_info_;
  93. }
  94. private:
  95. CallHook* call_hook_;
  96. grpc::CompletionQueue* cq_;
  97. grpc_call* call_;
  98. int max_receive_message_size_;
  99. experimental::ClientRpcInfo* client_rpc_info_ = nullptr;
  100. experimental::ServerRpcInfo* server_rpc_info_ = nullptr;
  101. };
  102. } // namespace internal
  103. } // namespace grpc
  104. #endif // GRPCPP_IMPL_CODEGEN_CALL_H