3 * Copyright 2018 gRPC authors.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #ifndef GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_SHARED_RESOURCE_H
20 #define GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_SHARED_RESOURCE_H
22 #include <grpc/support/port_platform.h>
24 #include <grpc/grpc.h>
25 #include <grpc/support/sync.h>
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"
32 * Main struct containing ALTS shared resources used when
33 * employing the dedicated completion queue and thread.
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;
41 grpc_channel* channel;
42 } alts_shared_resource_dedicated;
44 /* This method returns the address of alts_shared_resource_dedicated
45 * object shared by all TSI handshakes.
47 alts_shared_resource_dedicated* grpc_alts_get_shared_resource_dedicated(void);
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().
54 void grpc_alts_shared_resource_dedicated_shutdown();
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();
61 void grpc_alts_shared_resource_dedicated_init();
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.
69 void grpc_alts_shared_resource_dedicated_start(
70 const char* handshaker_service_url);
72 #endif /* GRPC_CORE_TSI_ALTS_HANDSHAKER_ALTS_SHARED_RESOURCE_H \