iomgr_windows.cc
Go to the documentation of this file.
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 
20 
22 
23 #ifdef GRPC_WINSOCK_SOCKET
24 
25 #include <grpc/support/log.h>
26 
37 
38 extern grpc_tcp_server_vtable grpc_windows_tcp_server_vtable;
39 extern grpc_tcp_client_vtable grpc_windows_tcp_client_vtable;
41 extern grpc_pollset_vtable grpc_windows_pollset_vtable;
42 extern grpc_pollset_set_vtable grpc_windows_pollset_set_vtable;
43 
44 /* Windows' io manager is going to be fully designed using IO completion
45  ports. All of what we're doing here is basically make sure that
46  Windows sockets are initialized in and out. */
47 
48 static void winsock_init(void) {
49  WSADATA wsaData;
50  int status = WSAStartup(MAKEWORD(2, 0), &wsaData);
51  GPR_ASSERT(status == 0);
52 }
53 
54 static void winsock_shutdown(void) {
55  int status = WSACleanup();
56  GPR_ASSERT(status == 0);
57 }
58 
59 static void iomgr_platform_init(void) {
60  winsock_init();
61  grpc_iocp_init();
63  grpc_wsa_socket_flags_init();
64 }
65 
66 static void iomgr_platform_flush(void) { grpc_iocp_flush(); }
67 
68 static void iomgr_platform_shutdown(void) {
70  grpc_iocp_shutdown();
71  winsock_shutdown();
72 }
73 
74 static void iomgr_platform_shutdown_background_closure(void) {}
75 
76 static bool iomgr_platform_is_any_background_poller_thread(void) {
77  return false;
78 }
79 
80 static bool iomgr_platform_add_closure_to_background_poller(
82  return false;
83 }
84 
86  iomgr_platform_init,
87  iomgr_platform_flush,
88  iomgr_platform_shutdown,
89  iomgr_platform_shutdown_background_closure,
90  iomgr_platform_is_any_background_poller_thread,
91  iomgr_platform_add_closure_to_background_poller};
92 
94  grpc_set_tcp_client_impl(&grpc_windows_tcp_client_vtable);
95  grpc_set_tcp_server_impl(&grpc_windows_tcp_server_vtable);
97  grpc_set_pollset_vtable(&grpc_windows_pollset_vtable);
98  grpc_set_pollset_set_vtable(&grpc_windows_pollset_set_vtable);
101 }
102 
103 bool grpc_iomgr_run_in_background() { return false; }
104 
105 #endif /* GRPC_WINSOCK_SOCKET */
grpc_pollset_vtable
Definition: pollset.h:41
iomgr.h
vtable
static const grpc_transport_vtable vtable
Definition: binder_transport.cc:680
log.h
pollset_windows.h
resolve_address_windows.h
grpc_timer_vtable
Definition: iomgr/timer.h:61
resolve_address.h
error
grpc_error_handle error
Definition: retry_filter.cc:499
status
absl::Status status
Definition: rls.cc:251
socket_windows.h
grpc_pollset_set_vtable
Definition: pollset_set.h:32
grpc_set_default_iomgr_platform
void grpc_set_default_iomgr_platform()
Definition: memory_quota_test.cc:167
iocp_windows.h
grpc_pollset_global_shutdown
void grpc_pollset_global_shutdown()
Definition: pollset.cc:31
grpc_set_timer_impl
void grpc_set_timer_impl(grpc_timer_vtable *vtable)
Definition: iomgr/timer.cc:27
grpc_set_iomgr_platform_vtable
void grpc_set_iomgr_platform_vtable(grpc_iomgr_platform_vtable *vtable)
Definition: iomgr_internal.cc:31
grpc_iomgr_run_in_background
bool grpc_iomgr_run_in_background()
grpc_pollset_global_init
void grpc_pollset_global_init()
Definition: pollset.cc:29
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
grpc_set_tcp_client_impl
void grpc_set_tcp_client_impl(grpc_tcp_client_vtable *impl)
Definition: tcp_client.cc:39
grpc_set_pollset_vtable
void grpc_set_pollset_vtable(grpc_pollset_vtable *vtable)
Definition: pollset.cc:25
tcp_client.h
grpc_set_pollset_set_vtable
void grpc_set_pollset_set_vtable(grpc_pollset_set_vtable *vtable)
Definition: pollset_set.cc:25
port.h
sockaddr_windows.h
grpc_core::SetDNSResolver
void SetDNSResolver(DNSResolver *resolver)
Definition: resolve_address.cc:36
grpc_generic_timer_vtable
grpc_timer_vtable grpc_generic_timer_vtable
Definition: timer_generic.cc:735
closure
Definition: proxy.cc:59
timer.h
grpc_tcp_client_vtable
Definition: tcp_client.h:32
grpc_error
Definition: error_internal.h:42
tcp_server.h
grpc_closure
Definition: closure.h:56
grpc_set_tcp_server_impl
void grpc_set_tcp_server_impl(grpc_tcp_server_vtable *impl)
Definition: tcp_server.cc:75
grpc_tcp_server_vtable
Definition: tcp_server.h:65
grpc_core::NativeDNSResolver::GetOrCreate
static NativeDNSResolver * GetOrCreate()
grpc_iomgr_platform_vtable
Definition: iomgr_internal.h:35
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:08