Resolve sanity

pull/18784/head
yang-g 6 years ago
parent 6929cdd654
commit 051d421579
  1. 6
      include/grpcpp/impl/codegen/message_allocator.h
  2. 4
      include/grpcpp/impl/codegen/server_callback.h
  3. 6
      include/grpcpp/support/message_allocator.h
  4. 28
      test/cpp/codegen/compiler_test_golden

@ -16,8 +16,8 @@
*
*/
#ifndef GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H_
#define GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H_
#ifndef GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H
#define GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H
namespace grpc {
@ -50,4 +50,4 @@ class MessageAllocator {
} // namespace grpc
#endif // GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H_
#endif // GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H

@ -604,8 +604,6 @@ class CallbackUnaryHandler : public MethodHandler {
ctx_->BeginCompletionOp(call, [this](bool) { MaybeDone(); }, nullptr);
}
~ServerCallbackRpcControllerImpl() {}
const RequestType* request() { return allocator_info_->request; }
ResponseType* response() { return allocator_info_->response; }
@ -613,7 +611,6 @@ class CallbackUnaryHandler : public MethodHandler {
if (--callbacks_outstanding_ == 0) {
grpc_call* call = call_.call();
auto call_requester = std::move(call_requester_);
this->~ServerCallbackRpcControllerImpl(); // explicitly call destructor
if (allocator_ != nullptr) {
allocator_->DeallocateMessages(allocator_info_);
} else {
@ -624,6 +621,7 @@ class CallbackUnaryHandler : public MethodHandler {
allocator_info_->response->~ResponseType();
}
}
this->~ServerCallbackRpcControllerImpl(); // explicitly call destructor
g_core_codegen_interface->grpc_call_unref(call);
call_requester();
}

@ -16,9 +16,9 @@
*
*/
#ifndef GRPCPP_SUPPORT_MESSAGE_ALLOCATOR_H_
#define GRPCPP_SUPPORT_MESSAGE_ALLOCATOR_H_
#ifndef GRPCPP_SUPPORT_MESSAGE_ALLOCATOR_H
#define GRPCPP_SUPPORT_MESSAGE_ALLOCATOR_H
#include <grpcpp/impl/codegen/message_allocator.h>
#endif // GRPCPP_SUPPORT_MESSAGE_ALLOCATOR_H_
#endif // GRPCPP_SUPPORT_MESSAGE_ALLOCATOR_H

@ -41,6 +41,8 @@
#include <grpcpp/impl/codegen/sync_stream.h>
namespace grpc {
template <typename RequestT, typename ResponseT>
class MessageAllocator;
class CompletionQueue;
class Channel;
class ServerCompletionQueue;
@ -330,7 +332,18 @@ class ServiceA final {
::grpc::testing::Response* response,
::grpc::experimental::ServerCallbackRpcController* controller) {
return this->MethodA1(context, request, response, controller);
}));
}, nullptr));
}
void SetMessageAllocatorFor_MethodA1(
::grpc::MessageAllocator<::grpc::testing::Request, ::grpc::testing::Response>* allocator) {
::grpc::Service::experimental().MarkMethodCallback(0,
new ::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>(
[this](::grpc::ServerContext* context,
const ::grpc::testing::Request* request,
::grpc::testing::Response* response,
::grpc::experimental::ServerCallbackRpcController* controller) {
return this->MethodA1(context, request, response, controller);
}, allocator));
}
~ExperimentalWithCallbackMethod_MethodA1() override {
BaseClassMustBeDerivedFromService(this);
@ -798,7 +811,18 @@ class ServiceB final {
::grpc::testing::Response* response,
::grpc::experimental::ServerCallbackRpcController* controller) {
return this->MethodB1(context, request, response, controller);
}));
}, nullptr));
}
void SetMessageAllocatorFor_MethodB1(
::grpc::MessageAllocator<::grpc::testing::Request, ::grpc::testing::Response>* allocator) {
::grpc::Service::experimental().MarkMethodCallback(0,
new ::grpc::internal::CallbackUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>(
[this](::grpc::ServerContext* context,
const ::grpc::testing::Request* request,
::grpc::testing::Response* response,
::grpc::experimental::ServerCallbackRpcController* controller) {
return this->MethodB1(context, request, response, controller);
}, allocator));
}
~ExperimentalWithCallbackMethod_MethodB1() override {
BaseClassMustBeDerivedFromService(this);

Loading…
Cancel
Save