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