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 GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H 20 #define GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H 21 22 #include <grpc/support/port_platform.h> 23 24 #include <grpc/support/sync.h> 25 26 #include "src/core/lib/iomgr/port.h" 27 28 #ifdef GRPC_WINSOCK_SOCKET 29 #include "src/core/lib/iomgr/socket_windows.h" 30 31 /* There isn't really any such thing as a pollset under Windows, due to the 32 nature of the IO completion ports. A Windows "pollset" is merely a mutex 33 used to synchronize with the IOCP, and workers are condition variables 34 used to block threads until work is ready. */ 35 36 typedef enum { 37 GRPC_POLLSET_WORKER_LINK_POLLSET = 0, 38 GRPC_POLLSET_WORKER_LINK_GLOBAL, 39 GRPC_POLLSET_WORKER_LINK_TYPES 40 } grpc_pollset_worker_link_type; 41 42 typedef struct grpc_pollset_worker_link { 43 struct grpc_pollset_worker* next; 44 struct grpc_pollset_worker* prev; 45 } grpc_pollset_worker_link; 46 47 struct grpc_pollset; 48 typedef struct grpc_pollset grpc_pollset; 49 50 typedef struct grpc_pollset_worker { 51 gpr_cv cv; 52 int kicked; 53 struct grpc_pollset* pollset; 54 grpc_pollset_worker_link links[GRPC_POLLSET_WORKER_LINK_TYPES]; 55 } grpc_pollset_worker; 56 57 struct grpc_pollset { 58 int shutting_down; 59 int kicked_without_pollers; 60 int is_iocp_worker; 61 grpc_pollset_worker root_worker; 62 grpc_closure* on_shutdown; 63 }; 64 65 void grpc_pollset_global_init(void); 66 void grpc_pollset_global_shutdown(void); 67 68 #endif 69 70 #endif /* GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H */ 71