grpcpp/impl/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>
27 #include <grpcpp/impl/codegen/grpc_library.h> // IWYU pragma: export
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::internal::GrpcLibraryInitializer::GrpcLibraryInitializer
GrpcLibraryInitializer()
Definition: grpcpp/impl/grpc_library.h:41
grpc
Definition: grpcpp/alarm.h:33
grpc::internal::GrpcLibraryInitializer::summon
int summon()
Definition: grpcpp/impl/grpc_library.h:54
core_codegen.h
config.h
grpc::GrpcLibraryInterface
Definition: grpcpp/impl/codegen/grpc_library.h:28
grpc::g_core_codegen_interface
CoreCodegenInterface * g_core_codegen_interface
Definition: include/grpcpp/impl/codegen/completion_queue.h:98
grpc::internal::GrpcLibraryInitializer
Instantiating this class ensures the proper initialization of gRPC.
Definition: grpcpp/impl/grpc_library.h:39
grpc.h
grpc::internal::GrpcLibrary
Definition: grpcpp/impl/grpc_library.h:32
grpc_library.h
grpc::CoreCodegen
Implementation of the core codegen interface.
Definition: grpcpp/impl/codegen/core_codegen.h:34
grpc::g_glip
GrpcLibraryInterface * g_glip
Definition: codegen_init.cc:30
grpc::internal::GrpcLibrary::init
void init() override
Definition: grpcpp/impl/grpc_library.h:34
grpc::internal::GrpcLibrary::shutdown
void shutdown() override
Definition: grpcpp/impl/grpc_library.h:35
internal
Definition: benchmark/test/output_test_helper.cc:20
grpc_init
GRPCAPI void grpc_init(void)
Definition: init.cc:146
grpc_shutdown
GRPCAPI void grpc_shutdown(void)
Definition: init.cc:209


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:47