• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SRC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H
20 #define GRPC_SRC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H
21 
22 #include <grpc/support/port_platform.h>
23 #include <grpc/support/sync.h>
24 
25 #include "src/core/lib/iomgr/port.h"
26 
27 #ifdef GRPC_WINSOCK_SOCKET
28 #include "src/core/lib/iomgr/socket_windows.h"
29 
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
32 // used to synchronize with the IOCP, and workers are condition variables
33 // used to block threads until work is ready.
34 
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 {
42   struct grpc_pollset_worker* next;
43   struct grpc_pollset_worker* prev;
44 } grpc_pollset_worker_link;
45 
46 struct grpc_pollset;
47 typedef struct grpc_pollset grpc_pollset;
48 
49 typedef struct grpc_pollset_worker {
50   gpr_cv cv;
51   int kicked;
52   struct grpc_pollset* pollset;
53   grpc_pollset_worker_link links[GRPC_POLLSET_WORKER_LINK_TYPES];
54 } grpc_pollset_worker;
55 
56 struct grpc_pollset {
57   int shutting_down;
58   int kicked_without_pollers;
59   int is_iocp_worker;
60   grpc_pollset_worker root_worker;
61   grpc_closure* on_shutdown;
62 };
63 
64 void grpc_pollset_global_init(void);
65 void grpc_pollset_global_shutdown(void);
66 
67 #endif
68 
69 #endif  // GRPC_SRC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H
70