Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/grpc/src/core/iomgr/pollset.h

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 *
3 * Copyright 2015-2016, Google Inc.
4 * 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
34 #ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_H
35 #define GRPC_INTERNAL_CORE_IOMGR_POLLSET_H
36
37 #include <grpc/support/port_platform.h>
38 #include <grpc/support/sync.h>
39 #include <grpc/support/time.h>
40
41 #include "src/core/iomgr/exec_ctx.h"
42
43 #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1)
44
45 /* A grpc_pollset is a set of file descriptors that a higher level item is
46 interested in. For example:
47 - a server will typically keep a pollset containing all connected channels,
48 so that it can find new calls to service
49 - a completion queue might keep a pollset with an entry for each transport
50 that is servicing a call that it's tracking */
51
52 typedef struct grpc_pollset grpc_pollset;
53 typedef struct grpc_pollset_worker grpc_pollset_worker;
54
55 size_t grpc_pollset_size(void);
56 void grpc_pollset_init(grpc_pollset *pollset, gpr_mu **mu);
57 /* Begin shutting down the pollset, and call closure when done.
58 * GRPC_POLLSET_MU(pollset) must be held */
59 void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
60 grpc_closure *closure);
61 /** Reset the pollset to its initial state (perhaps with some cached objects);
62 * must have been previously shutdown */
63 void grpc_pollset_reset(grpc_pollset *pollset);
64 void grpc_pollset_destroy(grpc_pollset *pollset);
65
66 /* Do some work on a pollset.
67 May involve invoking asynchronous callbacks, or actually polling file
68 descriptors.
69 Requires GRPC_POLLSET_MU(pollset) locked.
70 May unlock GRPC_POLLSET_MU(pollset) during its execution.
71
72 worker is a (platform-specific) handle that can be used to wake up
73 from grpc_pollset_work before any events are received and before the timeout
74 has expired. It is both initialized and destroyed by grpc_pollset_work.
75 Initialization of worker is guaranteed to occur BEFORE the
76 GRPC_POLLSET_MU(pollset) is released for the first time by
77 grpc_pollset_work, and it is guaranteed that GRPC_POLLSET_MU(pollset) will
78 not be released by grpc_pollset_work AFTER worker has been destroyed.
79
80 Tries not to block past deadline.
81 May call grpc_closure_list_run on grpc_closure_list, without holding the
82 pollset
83 lock */
84 void grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
85 grpc_pollset_worker **worker, gpr_timespec now,
86 gpr_timespec deadline);
87
88 /* Break one polling thread out of polling work for this pollset.
89 If specific_worker is GRPC_POLLSET_KICK_BROADCAST, kick ALL the workers.
90 Otherwise, if specific_worker is non-NULL, then kick that worker. */
91 void grpc_pollset_kick(grpc_pollset *pollset,
92 grpc_pollset_worker *specific_worker);
93
94 #endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_H */
OLDNEW
« no previous file with comments | « third_party/grpc/src/core/iomgr/iomgr_windows.c ('k') | third_party/grpc/src/core/iomgr/pollset_multipoller_with_epoll.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698