blob: 7733d26471c7d05ca06bcbb0eb3ef174637c467f [file] [log] [blame]
Craig Tillerf2d39b72015-01-21 15:06:08 -08001/*
2 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003 * Copyright 2015 gRPC authors.
Craig Tillerf2d39b72015-01-21 15:06:08 -08004 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02005 * 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 Tillerf2d39b72015-01-21 15:06:08 -08008 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009 * http://www.apache.org/licenses/LICENSE-2.0
Craig Tillerf2d39b72015-01-21 15:06:08 -080010 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +020011 * 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 Tillerf2d39b72015-01-21 15:06:08 -080016 *
17 */
18
Craig Tiller9a4dddd2016-03-25 17:08:13 -070019#ifndef GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H
20#define GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H
Craig Tillerf2d39b72015-01-21 15:06:08 -080021
22#include <grpc/support/sync.h>
23
Craig Tiller9533d042016-03-25 17:11:06 -070024#include "src/core/lib/iomgr/socket_windows.h"
Craig Tillerf2d39b72015-01-21 15:06:08 -080025
Yash Tibrewala7e6d652017-09-20 18:56:37 -070026#ifdef __cplusplus
27extern "C" {
28#endif
29
Nicolas "Pixel" Noble0f981e92015-05-03 10:40:56 +020030/* 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 Tiller060ca5f2015-08-04 08:24:48 -070032 used to synchronize with the IOCP, and workers are condition variables
33 used to block threads until work is ready. */
Craig Tillerf2d39b72015-01-21 15:06:08 -080034
Craig Tiller3dedb702015-09-24 10:31:26 -070035typedef 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
41typedef struct grpc_pollset_worker_link {
Craig Tillerd1885e02015-07-30 14:32:31 -070042 struct grpc_pollset_worker *next;
43 struct grpc_pollset_worker *prev;
Craig Tiller3dedb702015-09-24 10:31:26 -070044} grpc_pollset_worker_link;
45
Craig Tiller084c8082015-09-29 11:19:06 -070046struct grpc_pollset;
47typedef struct grpc_pollset grpc_pollset;
48
Craig Tiller3dedb702015-09-24 10:31:26 -070049typedef struct grpc_pollset_worker {
50 gpr_cv cv;
Craig Tiller084c8082015-09-29 11:19:06 -070051 int kicked;
52 struct grpc_pollset *pollset;
Craig Tiller3dedb702015-09-24 10:31:26 -070053 grpc_pollset_worker_link links[GRPC_POLLSET_WORKER_LINK_TYPES];
Craig Tillerd1885e02015-07-30 14:32:31 -070054} grpc_pollset_worker;
55
Craig Tiller084c8082015-09-29 11:19:06 -070056struct grpc_pollset {
Nicolas "Pixel" Noble857d2502015-06-25 21:58:18 +020057 int shutting_down;
Craig Tillerd1885e02015-07-30 14:32:31 -070058 int kicked_without_pollers;
Craig Tiller3dedb702015-09-24 10:31:26 -070059 int is_iocp_worker;
Craig Tillerd1885e02015-07-30 14:32:31 -070060 grpc_pollset_worker root_worker;
Craig Tiller3dedb702015-09-24 10:31:26 -070061 grpc_closure *on_shutdown;
Craig Tiller084c8082015-09-29 11:19:06 -070062};
Craig Tillerf2d39b72015-01-21 15:06:08 -080063
Craig Tiller4c33dba2016-03-31 10:35:00 -070064void grpc_pollset_global_init(void);
65void grpc_pollset_global_shutdown(void);
66
Yash Tibrewala7e6d652017-09-20 18:56:37 -070067#ifdef __cplusplus
68}
69#endif
70
71#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H */