diff options
Diffstat (limited to 'include/grpc++/impl/grpc_library.h')
-rw-r--r-- | include/grpc++/impl/grpc_library.h | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/include/grpc++/impl/grpc_library.h b/include/grpc++/impl/grpc_library.h index ce4211418d..e8a075f5eb 100644 --- a/include/grpc++/impl/grpc_library.h +++ b/include/grpc++/impl/grpc_library.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,16 +34,34 @@ #ifndef GRPCXX_IMPL_GRPC_LIBRARY_H #define GRPCXX_IMPL_GRPC_LIBRARY_H +#include <iostream> + +#include <grpc++/impl/codegen/config.h> +#include <grpc++/impl/codegen/grpc_library.h> #include <grpc/grpc.h> namespace grpc { -class GrpcLibrary { +namespace internal { +class GrpcLibrary GRPC_FINAL : public GrpcLibraryInterface { public: - GrpcLibrary() { grpc_init(); } - virtual ~GrpcLibrary() { grpc_shutdown(); } + void init() GRPC_OVERRIDE { grpc_init(); } + + void shutdown() GRPC_OVERRIDE { grpc_shutdown(); } +}; + +static GrpcLibrary g_gli; + +class GrpcLibraryInitializer GRPC_FINAL { + public: + GrpcLibraryInitializer() { grpc::g_glip = &g_gli; } + + /// A no-op method to force the linker to reference this class, which will + /// take care of initializing and shutting down the gRPC runtime. + int summon() { return 0; } }; +} // namespace internal } // namespace grpc #endif // GRPCXX_IMPL_GRPC_LIBRARY_H |