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

Side by Side Diff: third_party/grpc/src/core/iomgr/closure.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
« no previous file with comments | « third_party/grpc/src/core/httpcli/parser.c ('k') | third_party/grpc/src/core/iomgr/closure.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_CLOSURE_H
35 #define GRPC_INTERNAL_CORE_IOMGR_CLOSURE_H
36
37 #include <grpc/support/port_platform.h>
38 #include <stdbool.h>
39
40 struct grpc_closure;
41 typedef struct grpc_closure grpc_closure;
42
43 /* forward declaration for exec_ctx.h */
44 struct grpc_exec_ctx;
45 typedef struct grpc_exec_ctx grpc_exec_ctx;
46
47 typedef struct grpc_closure_list {
48 grpc_closure *head;
49 grpc_closure *tail;
50 } grpc_closure_list;
51
52 /** gRPC Callback definition.
53 *
54 * \param arg Arbitrary input.
55 * \param success An indication on the state of the iomgr. On false, cleanup
56 * actions should be taken (eg, shutdown). */
57 typedef void (*grpc_iomgr_cb_func)(grpc_exec_ctx *exec_ctx, void *arg,
58 bool success);
59
60 /** A closure over a grpc_iomgr_cb_func. */
61 struct grpc_closure {
62 /** Bound callback. */
63 grpc_iomgr_cb_func cb;
64
65 /** Arguments to be passed to "cb". */
66 void *cb_arg;
67
68 /** Once enqueued, contains in the lower bit the success of the closure,
69 and in the upper bits the pointer to the next closure in the list.
70 Before enqueing for execution, this is usable for scratch data. */
71 uintptr_t final_data;
72 };
73
74 /** Initializes \a closure with \a cb and \a cb_arg. */
75 void grpc_closure_init(grpc_closure *closure, grpc_iomgr_cb_func cb,
76 void *cb_arg);
77
78 /* Create a heap allocated closure: try to avoid except for very rare events */
79 grpc_closure *grpc_closure_create(grpc_iomgr_cb_func cb, void *cb_arg);
80
81 #define GRPC_CLOSURE_LIST_INIT \
82 { NULL, NULL }
83
84 /** add \a closure to the end of \a list and set \a closure's success to \a
85 * success */
86 void grpc_closure_list_add(grpc_closure_list *list, grpc_closure *closure,
87 bool success);
88
89 /** append all closures from \a src to \a dst and empty \a src. */
90 void grpc_closure_list_move(grpc_closure_list *src, grpc_closure_list *dst);
91
92 /** return whether \a list is empty. */
93 bool grpc_closure_list_empty(grpc_closure_list list);
94
95 /** return the next pointer for a queued closure list */
96 grpc_closure *grpc_closure_next(grpc_closure *closure);
97
98 #endif /* GRPC_INTERNAL_CORE_IOMGR_CLOSURE_H */
OLDNEW
« no previous file with comments | « third_party/grpc/src/core/httpcli/parser.c ('k') | third_party/grpc/src/core/iomgr/closure.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698