blob: 9deb0fa8faa845702924690aa2063420b09ff72d [file] [log] [blame]
Craig Tillerf2d39b72015-01-21 15:06:08 -08001/*
2 *
Craig Tiller06059952015-02-18 08:34:56 -08003 * Copyright 2015, Google Inc.
Craig Tillerf2d39b72015-01-21 15:06:08 -08004 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
Craig Tillerd14a1a52015-01-21 15:26:29 -080034#include <grpc/support/port_platform.h>
Craig Tillerf2d39b72015-01-21 15:06:08 -080035
Nicolas "Pixel" Noble21f627a2015-02-04 01:31:14 +010036#ifdef GPR_WINSOCK_SOCKET
Craig Tillerf2d39b72015-01-21 15:06:08 -080037
Nicolas "Pixel" Noble21f627a2015-02-04 01:31:14 +010038#include <grpc/support/thd.h>
39
40#include "src/core/iomgr/alarm_internal.h"
Nicolas "Pixel" Noble21f627a2015-02-04 01:31:14 +010041#include "src/core/iomgr/iomgr_internal.h"
42#include "src/core/iomgr/pollset_windows.h"
43
Nicolas "Pixel" Noble0f981e92015-05-03 10:40:56 +020044/* There isn't really any such thing as a pollset under Windows, due to the
45 nature of the IO completion ports. We're still going to provide a minimal
46 set of features for the sake of the rest of grpc. But grpc_pollset_work
47 won't actually do any polling, and return as quickly as possible. */
48
Craig Tiller8674cb12015-06-05 07:09:25 -070049void grpc_pollset_init(grpc_pollset *pollset) { gpr_mu_init(&pollset->mu); }
Nicolas "Pixel" Noble21f627a2015-02-04 01:31:14 +010050
David Klempnerb5056612015-02-24 14:22:50 -080051void grpc_pollset_shutdown(grpc_pollset *pollset,
52 void (*shutdown_done)(void *arg),
53 void *shutdown_done_arg) {
54 shutdown_done(shutdown_done_arg);
55}
56
Nicolas "Pixel" Noble21f627a2015-02-04 01:31:14 +010057void grpc_pollset_destroy(grpc_pollset *pollset) {
Nicolas "Pixel" Nobleee0c96c2015-02-04 23:35:41 +010058 gpr_mu_destroy(&pollset->mu);
Nicolas "Pixel" Noble21f627a2015-02-04 01:31:14 +010059}
60
61int grpc_pollset_work(grpc_pollset *pollset, gpr_timespec deadline) {
62 gpr_timespec now;
63 now = gpr_now();
64 if (gpr_time_cmp(now, deadline) > 0) {
David Garcia Quintas1c762bd2015-05-31 17:04:43 -070065 return 0 /* GPR_FALSE */;
Nicolas "Pixel" Noble21f627a2015-02-04 01:31:14 +010066 }
David Garcia Quintas1c762bd2015-05-31 17:04:43 -070067 if (grpc_maybe_call_delayed_callbacks(NULL, 1 /* GPR_TRUE */)) {
68 return 1 /* GPR_TRUE */;
Nicolas "Pixel" Noble21f627a2015-02-04 01:31:14 +010069 }
70 if (grpc_alarm_check(NULL, now, &deadline)) {
David Garcia Quintas1c762bd2015-05-31 17:04:43 -070071 return 1 /* GPR_TRUE */;
Nicolas "Pixel" Noble21f627a2015-02-04 01:31:14 +010072 }
David Garcia Quintas1c762bd2015-05-31 17:04:43 -070073 return 0 /* GPR_FALSE */;
Nicolas "Pixel" Noble21f627a2015-02-04 01:31:14 +010074}
75
Craig Tiller8674cb12015-06-05 07:09:25 -070076void grpc_pollset_kick(grpc_pollset *p) {}
Nicolas "Pixel" Noble21f627a2015-02-04 01:31:14 +010077
Craig Tiller8674cb12015-06-05 07:09:25 -070078#endif /* GPR_WINSOCK_SOCKET */