commit
7da453630e
File diff suppressed because it is too large
Load Diff
@ -1,47 +0,0 @@
|
||||
diff --git a/include/grpcpp/impl/codegen/completion_queue.h b/include/grpcpp/impl/codegen/completion_queue.h
|
||||
index 80c7c41982..3f7d8a7714 100644
|
||||
--- a/include/grpcpp/impl/codegen/completion_queue.h
|
||||
+++ b/include/grpcpp/impl/codegen/completion_queue.h
|
||||
@@ -32,6 +32,8 @@
|
||||
#ifndef GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_H
|
||||
#define GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_H
|
||||
|
||||
+#include <typeinfo>
|
||||
+
|
||||
#include <grpc/impl/codegen/atm.h>
|
||||
#include <grpcpp/impl/codegen/completion_queue_tag.h>
|
||||
#include <grpcpp/impl/codegen/core_codegen_interface.h>
|
||||
@@ -106,7 +108,9 @@ class CompletionQueue : private GrpcLibraryCodegen {
|
||||
|
||||
/// Destructor. Destroys the owned wrapped completion queue / instance.
|
||||
~CompletionQueue() {
|
||||
- g_core_codegen_interface->grpc_completion_queue_destroy(cq_);
|
||||
+ if (typeid(*g_core_codegen_interface).hash_code() != typeid(CoreCodegenInterface).hash_code()) {
|
||||
+ g_core_codegen_interface->grpc_completion_queue_destroy(cq_);
|
||||
+ }
|
||||
}
|
||||
|
||||
/// Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT.
|
||||
diff --git a/include/grpcpp/impl/codegen/grpc_library.h b/include/grpcpp/impl/codegen/grpc_library.h
|
||||
index 17c904d71a..a092b2204d 100644
|
||||
--- a/include/grpcpp/impl/codegen/grpc_library.h
|
||||
+++ b/include/grpcpp/impl/codegen/grpc_library.h
|
||||
@@ -19,6 +19,8 @@
|
||||
#ifndef GRPCPP_IMPL_CODEGEN_GRPC_LIBRARY_H
|
||||
#define GRPCPP_IMPL_CODEGEN_GRPC_LIBRARY_H
|
||||
|
||||
+#include <typeinfo>
|
||||
+
|
||||
#include <grpcpp/impl/codegen/core_codegen_interface.h>
|
||||
|
||||
namespace grpc {
|
||||
@@ -47,7 +49,8 @@ class GrpcLibraryCodegen {
|
||||
}
|
||||
}
|
||||
virtual ~GrpcLibraryCodegen() {
|
||||
- if (grpc_init_called_) {
|
||||
+ if (grpc_init_called_ &&
|
||||
+ typeid(*g_glip).hash_code() != typeid(GrpcLibraryInterface).hash_code()) {
|
||||
GPR_CODEGEN_ASSERT(g_glip &&
|
||||
"gRPC library not initialized. See "
|
||||
"grpc::internal::GrpcLibraryInitializer.");
|
@ -0,0 +1,64 @@
|
||||
// Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef GRPCPP_IMPL_CODEGEN_GRPC_LIBRARY_H
|
||||
#define GRPCPP_IMPL_CODEGEN_GRPC_LIBRARY_H
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
#include <grpcpp/impl/codegen/core_codegen_interface.h>
|
||||
|
||||
namespace grpc {
|
||||
|
||||
class GrpcLibraryInterface {
|
||||
public:
|
||||
virtual ~GrpcLibraryInterface() = default;
|
||||
virtual void init() = 0;
|
||||
virtual void shutdown() = 0;
|
||||
};
|
||||
|
||||
/// Initialized by \a grpc::GrpcLibraryInitializer from
|
||||
/// <grpcpp/impl/grpc_library.h>
|
||||
extern GrpcLibraryInterface* g_glip;
|
||||
|
||||
/// Classes that require gRPC to be initialized should inherit from this class.
|
||||
class GrpcLibraryCodegen {
|
||||
public:
|
||||
GrpcLibraryCodegen(bool call_grpc_init = true) : grpc_init_called_(false) {
|
||||
if (call_grpc_init) {
|
||||
GPR_CODEGEN_ASSERT(g_glip &&
|
||||
"gRPC library not initialized. See "
|
||||
"grpc::internal::GrpcLibraryInitializer.");
|
||||
g_glip->init();
|
||||
grpc_init_called_ = true;
|
||||
}
|
||||
}
|
||||
virtual ~GrpcLibraryCodegen() {
|
||||
if (grpc_init_called_ &&
|
||||
typeid(*g_glip).hash_code() !=
|
||||
typeid(GrpcLibraryInterface).hash_code()) {
|
||||
GPR_CODEGEN_ASSERT(g_glip &&
|
||||
"gRPC library not initialized. See "
|
||||
"grpc::internal::GrpcLibraryInitializer.");
|
||||
g_glip->shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool grpc_init_called_;
|
||||
};
|
||||
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPCPP_IMPL_CODEGEN_GRPC_LIBRARY_H
|
Loading…
Reference in new issue