• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  * Copyright 2018 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 GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_SHARED_RESOURCE_H
20 #define GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_SHARED_RESOURCE_H
21 
22 #include <grpc/support/port_platform.h>
23 
24 #include <grpc/grpc.h>
25 #include <grpc/support/sync.h>
26 
27 #include "src/core/lib/gprpp/thd.h"
28 #include "src/core/lib/iomgr/pollset_set.h"
29 #include "src/core/lib/surface/completion_queue.h"
30 
31 /**
32  * Main struct containing ALTS shared resources used when
33  * employing the dedicated completion queue and thread.
34  */
35 typedef struct alts_shared_resource_dedicated {
36   grpc_core::Thread thread;
37   grpc_completion_queue* cq;
38   grpc_pollset_set* interested_parties;
39   grpc_cq_completion storage;
40   gpr_mu mu;
41   grpc_channel* channel;
42 } alts_shared_resource_dedicated;
43 
44 /* This method returns the address of alts_shared_resource_dedicated
45  * object shared by all TSI handshakes.
46  */
47 alts_shared_resource_dedicated* grpc_alts_get_shared_resource_dedicated(void);
48 
49 /**
50  * This method destroys the alts_shared_resource_dedicated object
51  * shared by all TSI handshakes. The application is responsible for
52  * invoking the API before calling grpc_shutdown().
53  */
54 void grpc_alts_shared_resource_dedicated_shutdown();
55 
56 /**
57  * This method initializes the alts_shared_resource_dedicated object
58  * shared by all TSI handshakes. The application is responsible for
59  * invoking the API after calling grpc_init();
60  */
61 void grpc_alts_shared_resource_dedicated_init();
62 
63 /**
64  * This method populates various fields of the alts_shared_resource_dedicated
65  * object shared by all TSI handshakes and start the dedicated thread.
66  * The API will be invoked by the caller in a lazy manner. That is,
67  * it will get invoked when ALTS TSI handshake occurs for the first time.
68  */
69 void grpc_alts_shared_resource_dedicated_start(
70     const char* handshaker_service_url);
71 
72 #endif /* GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_SHARED_RESOURCE_H \
73         */
74