aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpc++
diff options
context:
space:
mode:
authorGravatar Sree Kuchibhotla <sreek@google.com>2017-03-30 13:20:00 -0700
committerGravatar Sree Kuchibhotla <sreek@google.com>2017-03-30 13:20:00 -0700
commite04906dc54e95f16bea7146459dfc1ab599b3826 (patch)
tree00d308fc6b431548a23e1a619ea6d77187f7dde0 /include/grpc++
parent359ffd83e01e236edd8d96b8ff7e9c326354c6fb (diff)
parentbea49665d418b69597b6bc058dd78744c0fa494d (diff)
Merge branch 'master' into cq_create_api_changes
Diffstat (limited to 'include/grpc++')
-rw-r--r--include/grpc++/impl/codegen/grpc_library.h26
1 files changed, 17 insertions, 9 deletions
diff --git a/include/grpc++/impl/codegen/grpc_library.h b/include/grpc++/impl/codegen/grpc_library.h
index 2b11aff214..3735d04e8c 100644
--- a/include/grpc++/impl/codegen/grpc_library.h
+++ b/include/grpc++/impl/codegen/grpc_library.h
@@ -51,18 +51,26 @@ extern GrpcLibraryInterface* g_glip;
/// Classes that require gRPC to be initialized should inherit from this class.
class GrpcLibraryCodegen {
public:
- GrpcLibraryCodegen() {
- GPR_CODEGEN_ASSERT(g_glip &&
- "gRPC library not initialized. See "
- "grpc::internal::GrpcLibraryInitializer.");
- g_glip->init();
+ 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() {
- GPR_CODEGEN_ASSERT(g_glip &&
- "gRPC library not initialized. See "
- "grpc::internal::GrpcLibraryInitializer.");
- g_glip->shutdown();
+ if (grpc_init_called_) {
+ GPR_CODEGEN_ASSERT(g_glip &&
+ "gRPC library not initialized. See "
+ "grpc::internal::GrpcLibraryInitializer.");
+ g_glip->shutdown();
+ }
}
+
+ private:
+ bool grpc_init_called_;
};
} // namespace grpc