GRPC C++  1.30.0
grpc_library.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 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 
19 #ifndef GRPCPP_IMPL_GRPC_LIBRARY_H
20 #define GRPCPP_IMPL_GRPC_LIBRARY_H
21 
22 #include <iostream>
23 
24 #include <grpc/grpc.h>
28 
29 namespace grpc {
30 
31 namespace internal {
32 class GrpcLibrary final : public GrpcLibraryInterface {
33  public:
34  void init() override { grpc_init(); }
35  void shutdown() override { grpc_shutdown(); }
36 };
37 
40  public:
42  if (grpc::g_glip == nullptr) {
43  static auto* const g_gli = new GrpcLibrary();
44  grpc::g_glip = g_gli;
45  }
46  if (grpc::g_core_codegen_interface == nullptr) {
47  static auto* const g_core_codegen = new CoreCodegen();
48  grpc::g_core_codegen_interface = g_core_codegen;
49  }
50  }
51 
54  int summon() { return 0; }
55 };
56 
57 } // namespace internal
58 } // namespace grpc
59 
60 #endif // GRPCPP_IMPL_GRPC_LIBRARY_H
grpc
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
grpc::CoreCodegen
Implementation of the core codegen interface.
Definition: core_codegen.h:32
config.h
core_codegen.h
grpc.h
grpc::internal::GrpcLibraryInitializer
Instantiating this class ensures the proper initialization of gRPC.
Definition: grpc_library.h:39
grpc::internal::GrpcLibraryInitializer::GrpcLibraryInitializer
GrpcLibraryInitializer()
Definition: grpc_library.h:41
grpc::internal::GrpcLibrary::init
void init() override
Definition: grpc_library.h:34
grpc::internal::GrpcLibraryInitializer::summon
int summon()
A no-op method to force the linker to reference this class, which will take care of initializing and ...
Definition: grpc_library.h:54
grpc::GrpcLibraryInterface
Definition: grpc_library.h:26
grpc::internal::GrpcLibrary
Definition: grpc_library.h:32
grpc_library.h
grpc::g_glip
GrpcLibraryInterface * g_glip
Initialized by grpc::GrpcLibraryInitializer from <grpcpp/impl/grpc_library.h>
grpc::g_core_codegen_interface
CoreCodegenInterface * g_core_codegen_interface
Definition: completion_queue_impl.h:93
grpc_init
GRPCAPI void grpc_init(void)
Initialize the grpc library.
grpc::internal::GrpcLibrary::shutdown
void shutdown() override
Definition: grpc_library.h:35
grpc_shutdown
GRPCAPI void grpc_shutdown(void)
Shut down the grpc library.