Craig Tiller | f2d39b7 | 2015-01-21 15:06:08 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | * Copyright 2015 gRPC authors. |
Craig Tiller | f2d39b7 | 2015-01-21 15:06:08 -0800 | [diff] [blame] | 4 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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 |
Craig Tiller | f2d39b7 | 2015-01-21 15:06:08 -0800 | [diff] [blame] | 8 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Craig Tiller | f2d39b7 | 2015-01-21 15:06:08 -0800 | [diff] [blame] | 10 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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. |
Craig Tiller | f2d39b7 | 2015-01-21 15:06:08 -0800 | [diff] [blame] | 16 | * |
| 17 | */ |
| 18 | |
Craig Tiller | 9a4dddd | 2016-03-25 17:08:13 -0700 | [diff] [blame] | 19 | #ifndef GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H |
| 20 | #define GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H |
Craig Tiller | f2d39b7 | 2015-01-21 15:06:08 -0800 | [diff] [blame] | 21 | |
| 22 | #include <grpc/support/sync.h> |
| 23 | |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 24 | #include "src/core/lib/iomgr/socket_windows.h" |
Craig Tiller | f2d39b7 | 2015-01-21 15:06:08 -0800 | [diff] [blame] | 25 | |
Yash Tibrewal | a7e6d65 | 2017-09-20 18:56:37 -0700 | [diff] [blame] | 26 | #ifdef __cplusplus |
| 27 | extern "C" { |
| 28 | #endif |
| 29 | |
Nicolas "Pixel" Noble | 0f981e9 | 2015-05-03 10:40:56 +0200 | [diff] [blame] | 30 | /* There isn't really any such thing as a pollset under Windows, due to the |
| 31 | nature of the IO completion ports. A Windows "pollset" is merely a mutex |
Craig Tiller | 060ca5f | 2015-08-04 08:24:48 -0700 | [diff] [blame] | 32 | used to synchronize with the IOCP, and workers are condition variables |
| 33 | used to block threads until work is ready. */ |
Craig Tiller | f2d39b7 | 2015-01-21 15:06:08 -0800 | [diff] [blame] | 34 | |
Craig Tiller | 3dedb70 | 2015-09-24 10:31:26 -0700 | [diff] [blame] | 35 | typedef enum { |
| 36 | GRPC_POLLSET_WORKER_LINK_POLLSET = 0, |
| 37 | GRPC_POLLSET_WORKER_LINK_GLOBAL, |
| 38 | GRPC_POLLSET_WORKER_LINK_TYPES |
| 39 | } grpc_pollset_worker_link_type; |
| 40 | |
| 41 | typedef struct grpc_pollset_worker_link { |
Craig Tiller | d1885e0 | 2015-07-30 14:32:31 -0700 | [diff] [blame] | 42 | struct grpc_pollset_worker *next; |
| 43 | struct grpc_pollset_worker *prev; |
Craig Tiller | 3dedb70 | 2015-09-24 10:31:26 -0700 | [diff] [blame] | 44 | } grpc_pollset_worker_link; |
| 45 | |
Craig Tiller | 084c808 | 2015-09-29 11:19:06 -0700 | [diff] [blame] | 46 | struct grpc_pollset; |
| 47 | typedef struct grpc_pollset grpc_pollset; |
| 48 | |
Craig Tiller | 3dedb70 | 2015-09-24 10:31:26 -0700 | [diff] [blame] | 49 | typedef struct grpc_pollset_worker { |
| 50 | gpr_cv cv; |
Craig Tiller | 084c808 | 2015-09-29 11:19:06 -0700 | [diff] [blame] | 51 | int kicked; |
| 52 | struct grpc_pollset *pollset; |
Craig Tiller | 3dedb70 | 2015-09-24 10:31:26 -0700 | [diff] [blame] | 53 | grpc_pollset_worker_link links[GRPC_POLLSET_WORKER_LINK_TYPES]; |
Craig Tiller | d1885e0 | 2015-07-30 14:32:31 -0700 | [diff] [blame] | 54 | } grpc_pollset_worker; |
| 55 | |
Craig Tiller | 084c808 | 2015-09-29 11:19:06 -0700 | [diff] [blame] | 56 | struct grpc_pollset { |
Nicolas "Pixel" Noble | 857d250 | 2015-06-25 21:58:18 +0200 | [diff] [blame] | 57 | int shutting_down; |
Craig Tiller | d1885e0 | 2015-07-30 14:32:31 -0700 | [diff] [blame] | 58 | int kicked_without_pollers; |
Craig Tiller | 3dedb70 | 2015-09-24 10:31:26 -0700 | [diff] [blame] | 59 | int is_iocp_worker; |
Craig Tiller | d1885e0 | 2015-07-30 14:32:31 -0700 | [diff] [blame] | 60 | grpc_pollset_worker root_worker; |
Craig Tiller | 3dedb70 | 2015-09-24 10:31:26 -0700 | [diff] [blame] | 61 | grpc_closure *on_shutdown; |
Craig Tiller | 084c808 | 2015-09-29 11:19:06 -0700 | [diff] [blame] | 62 | }; |
Craig Tiller | f2d39b7 | 2015-01-21 15:06:08 -0800 | [diff] [blame] | 63 | |
Craig Tiller | 4c33dba | 2016-03-31 10:35:00 -0700 | [diff] [blame] | 64 | void grpc_pollset_global_init(void); |
| 65 | void grpc_pollset_global_shutdown(void); |
| 66 | |
Yash Tibrewal | a7e6d65 | 2017-09-20 18:56:37 -0700 | [diff] [blame] | 67 | #ifdef __cplusplus |
| 68 | } |
| 69 | #endif |
| 70 | |
| 71 | #endif /* GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H */ |