diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/iomgr/alarm.h | 1 | ||||
-rw-r--r-- | src/core/iomgr/alarm_internal.h | 1 | ||||
-rw-r--r-- | src/core/iomgr/closure.c | 83 | ||||
-rw-r--r-- | src/core/iomgr/closure.h | 85 | ||||
-rw-r--r-- | src/core/iomgr/exec_ctx.h | 39 | ||||
-rw-r--r-- | src/core/iomgr/iomgr.c | 49 | ||||
-rw-r--r-- | src/core/iomgr/iomgr.h | 46 | ||||
-rw-r--r-- | src/core/iomgr/pollset_posix.h | 1 | ||||
-rw-r--r-- | src/core/iomgr/resolve_address.h | 1 | ||||
-rw-r--r-- | src/core/iomgr/workqueue.h | 1 | ||||
-rw-r--r-- | src/core/transport/chttp2/frame_data.h | 2 | ||||
-rw-r--r-- | src/core/transport/chttp2/frame_goaway.h | 2 | ||||
-rw-r--r-- | src/core/transport/chttp2/frame_ping.h | 2 | ||||
-rw-r--r-- | src/core/transport/chttp2/frame_rst_stream.h | 2 | ||||
-rw-r--r-- | src/core/transport/chttp2/frame_settings.h | 2 | ||||
-rw-r--r-- | src/core/transport/chttp2/frame_window_update.h | 2 | ||||
-rw-r--r-- | src/core/transport/chttp2/hpack_parser.h | 2 | ||||
-rw-r--r-- | src/core/transport/connectivity_state.h | 2 |
18 files changed, 220 insertions, 103 deletions
diff --git a/src/core/iomgr/alarm.h b/src/core/iomgr/alarm.h index 09bfa88756..e420c3a910 100644 --- a/src/core/iomgr/alarm.h +++ b/src/core/iomgr/alarm.h @@ -35,6 +35,7 @@ #define GRPC_INTERNAL_CORE_IOMGR_ALARM_H #include "src/core/iomgr/iomgr.h" +#include "src/core/iomgr/exec_ctx.h" #include <grpc/support/port_platform.h> #include <grpc/support/time.h> diff --git a/src/core/iomgr/alarm_internal.h b/src/core/iomgr/alarm_internal.h index aebc789ec6..4d6076ac5c 100644 --- a/src/core/iomgr/alarm_internal.h +++ b/src/core/iomgr/alarm_internal.h @@ -34,6 +34,7 @@ #ifndef GRPC_INTERNAL_CORE_IOMGR_ALARM_INTERNAL_H #define GRPC_INTERNAL_CORE_IOMGR_ALARM_INTERNAL_H +#include "src/core/iomgr/exec_ctx.h" #include <grpc/support/sync.h> #include <grpc/support/time.h> diff --git a/src/core/iomgr/closure.c b/src/core/iomgr/closure.c new file mode 100644 index 0000000000..1827ac3e28 --- /dev/null +++ b/src/core/iomgr/closure.c @@ -0,0 +1,83 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/iomgr/closure.h" + +void grpc_closure_init(grpc_closure *closure, grpc_iomgr_cb_func cb, + void *cb_arg) { + closure->cb = cb; + closure->cb_arg = cb_arg; + closure->next = NULL; +} + +void grpc_closure_list_add(grpc_closure_list *closure_list, + grpc_closure *closure, int success) { + if (closure == NULL) return; + closure->next = NULL; + closure->success = success; + if (closure_list->head == NULL) { + closure_list->head = closure; + } else { + closure_list->tail->next = closure; + } + closure_list->tail = closure; +} + +void grpc_closure_list_run(grpc_closure_list *closure_list) { + while (!grpc_closure_list_empty(*closure_list)) { + grpc_closure *c = closure_list->head; + closure_list->head = closure_list->tail = NULL; + while (c != NULL) { + grpc_closure *next = c->next; + c->cb(c->cb_arg, c->success, closure_list); + c = next; + } + } +} + +int grpc_closure_list_empty(grpc_closure_list closure_list) { + return closure_list.head == NULL; +} + +void grpc_closure_list_move(grpc_closure_list *src, grpc_closure_list *dst) { + if (src->head == NULL) { + return; + } + if (dst->head == NULL) { + *dst = *src; + } else { + dst->tail->next = src->head; + dst->tail = src->tail; + } + src->head = src->tail = NULL; +} diff --git a/src/core/iomgr/closure.h b/src/core/iomgr/closure.h new file mode 100644 index 0000000000..e8e1e04614 --- /dev/null +++ b/src/core/iomgr/closure.h @@ -0,0 +1,85 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_INTERNAL_CORE_IOMGR_CLOSURE_H +#define GRPC_INTERNAL_CORE_IOMGR_CLOSURE_H + +#include <stddef.h> + +struct grpc_closure; +typedef struct grpc_closure grpc_closure; + +typedef struct grpc_closure_list { + grpc_closure *head; + grpc_closure *tail; +} grpc_closure_list; + +/** gRPC Callback definition. + * + * \param arg Arbitrary input. + * \param success An indication on the state of the iomgr. On false, cleanup + * actions should be taken (eg, shutdown). */ +typedef void (*grpc_iomgr_cb_func)(void *arg, int success, + grpc_closure_list *closure_list); + +/** A closure over a grpc_iomgr_cb_func. */ +struct grpc_closure { + /** Bound callback. */ + grpc_iomgr_cb_func cb; + + /** Arguments to be passed to "cb". */ + void *cb_arg; + + /** Internal. A boolean indication to "cb" on the state of the iomgr. + * For instance, closures created during a shutdown would have this field set + * to false. */ + int success; + + /**< Internal. Do not touch */ + struct grpc_closure *next; +}; + +/** Initializes \a closure with \a cb and \a cb_arg. */ +void grpc_closure_init(grpc_closure *closure, grpc_iomgr_cb_func cb, + void *cb_arg); + +#define GRPC_CLOSURE_LIST_INIT \ + { NULL, NULL } + +void grpc_closure_list_add(grpc_closure_list *list, grpc_closure *closure, + int success); +void grpc_closure_list_run(grpc_closure_list *list); +void grpc_closure_list_move(grpc_closure_list *src, grpc_closure_list *dst); +int grpc_closure_list_empty(grpc_closure_list list); + +#endif /* GRPC_INTERNAL_CORE_IOMGR_CLOSURE_H */ diff --git a/src/core/iomgr/exec_ctx.h b/src/core/iomgr/exec_ctx.h new file mode 100644 index 0000000000..4d30feb26b --- /dev/null +++ b/src/core/iomgr/exec_ctx.h @@ -0,0 +1,39 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_INTERNAL_CORE_IOMGR_EXEC_CTX_H +#define GRPC_INTERNAL_CORE_IOMGR_EXEC_CTX_H + +#include "src/core/iomgr/closure.h" + +#endif diff --git a/src/core/iomgr/iomgr.c b/src/core/iomgr/iomgr.c index 9456bad716..f009eb3f69 100644 --- a/src/core/iomgr/iomgr.c +++ b/src/core/iomgr/iomgr.c @@ -160,52 +160,3 @@ void grpc_iomgr_unregister_object(grpc_iomgr_object *obj) { gpr_mu_unlock(&g_mu); gpr_free(obj->name); } - -void grpc_closure_init(grpc_closure *closure, grpc_iomgr_cb_func cb, - void *cb_arg) { - closure->cb = cb; - closure->cb_arg = cb_arg; - closure->next = NULL; -} - -void grpc_closure_list_add(grpc_closure_list *closure_list, - grpc_closure *closure, int success) { - if (closure == NULL) return; - closure->next = NULL; - closure->success = success; - if (closure_list->head == NULL) { - closure_list->head = closure; - } else { - closure_list->tail->next = closure; - } - closure_list->tail = closure; -} - -void grpc_closure_list_run(grpc_closure_list *closure_list) { - while (!grpc_closure_list_empty(*closure_list)) { - grpc_closure *c = closure_list->head; - closure_list->head = closure_list->tail = NULL; - while (c != NULL) { - grpc_closure *next = c->next; - c->cb(c->cb_arg, c->success, closure_list); - c = next; - } - } -} - -int grpc_closure_list_empty(grpc_closure_list closure_list) { - return closure_list.head == NULL; -} - -void grpc_closure_list_move(grpc_closure_list *src, grpc_closure_list *dst) { - if (src->head == NULL) { - return; - } - if (dst->head == NULL) { - *dst = *src; - } else { - dst->tail->next = src->head; - dst->tail = src->tail; - } - src->head = src->tail = NULL; -} diff --git a/src/core/iomgr/iomgr.h b/src/core/iomgr/iomgr.h index bc015706a3..c9ea84c605 100644 --- a/src/core/iomgr/iomgr.h +++ b/src/core/iomgr/iomgr.h @@ -34,52 +34,6 @@ #ifndef GRPC_INTERNAL_CORE_IOMGR_IOMGR_H #define GRPC_INTERNAL_CORE_IOMGR_IOMGR_H -struct grpc_closure; -typedef struct grpc_closure grpc_closure; - -typedef struct grpc_closure_list { - grpc_closure *head; - grpc_closure *tail; -} grpc_closure_list; - -/** gRPC Callback definition. - * - * \param arg Arbitrary input. - * \param success An indication on the state of the iomgr. On false, cleanup - * actions should be taken (eg, shutdown). */ -typedef void (*grpc_iomgr_cb_func)(void *arg, int success, - grpc_closure_list *closure_list); - -/** A closure over a grpc_iomgr_cb_func. */ -struct grpc_closure { - /** Bound callback. */ - grpc_iomgr_cb_func cb; - - /** Arguments to be passed to "cb". */ - void *cb_arg; - - /** Internal. A boolean indication to "cb" on the state of the iomgr. - * For instance, closures created during a shutdown would have this field set - * to false. */ - int success; - - /**< Internal. Do not touch */ - struct grpc_closure *next; -}; - -/** Initializes \a closure with \a cb and \a cb_arg. */ -void grpc_closure_init(grpc_closure *closure, grpc_iomgr_cb_func cb, - void *cb_arg); - -#define GRPC_CLOSURE_LIST_INIT \ - { NULL, NULL } - -void grpc_closure_list_add(grpc_closure_list *list, grpc_closure *closure, - int success); -void grpc_closure_list_run(grpc_closure_list *list); -void grpc_closure_list_move(grpc_closure_list *src, grpc_closure_list *dst); -int grpc_closure_list_empty(grpc_closure_list list); - /** Initializes the iomgr. */ void grpc_iomgr_init(void); diff --git a/src/core/iomgr/pollset_posix.h b/src/core/iomgr/pollset_posix.h index 2f50cd2209..4064d117b7 100644 --- a/src/core/iomgr/pollset_posix.h +++ b/src/core/iomgr/pollset_posix.h @@ -37,6 +37,7 @@ #include <poll.h> #include <grpc/support/sync.h> +#include "src/core/iomgr/exec_ctx.h" #include "src/core/iomgr/iomgr.h" #include "src/core/iomgr/wakeup_fd_posix.h" diff --git a/src/core/iomgr/resolve_address.h b/src/core/iomgr/resolve_address.h index 174432225e..54e8add560 100644 --- a/src/core/iomgr/resolve_address.h +++ b/src/core/iomgr/resolve_address.h @@ -35,6 +35,7 @@ #define GRPC_INTERNAL_CORE_IOMGR_RESOLVE_ADDRESS_H #include <stddef.h> +#include "src/core/iomgr/exec_ctx.h" #include "src/core/iomgr/iomgr.h" #define GRPC_MAX_SOCKADDR_SIZE 128 diff --git a/src/core/iomgr/workqueue.h b/src/core/iomgr/workqueue.h index 0bec714d4f..0bc7e314e1 100644 --- a/src/core/iomgr/workqueue.h +++ b/src/core/iomgr/workqueue.h @@ -36,6 +36,7 @@ #include "src/core/iomgr/iomgr.h" #include "src/core/iomgr/pollset.h" +#include "src/core/iomgr/closure.h" #ifdef GPR_POSIX_SOCKET #include "src/core/iomgr/workqueue_posix.h" diff --git a/src/core/transport/chttp2/frame_data.h b/src/core/transport/chttp2/frame_data.h index 89a503eb7c..ccd56a132c 100644 --- a/src/core/transport/chttp2/frame_data.h +++ b/src/core/transport/chttp2/frame_data.h @@ -36,7 +36,7 @@ /* Parser for GRPC streams embedded in DATA frames */ -#include "src/core/iomgr/iomgr.h" +#include "src/core/iomgr/exec_ctx.h" #include <grpc/support/slice.h> #include <grpc/support/slice_buffer.h> #include "src/core/transport/stream_op.h" diff --git a/src/core/transport/chttp2/frame_goaway.h b/src/core/transport/chttp2/frame_goaway.h index 6f9ce94a0c..e45d55418c 100644 --- a/src/core/transport/chttp2/frame_goaway.h +++ b/src/core/transport/chttp2/frame_goaway.h @@ -34,7 +34,7 @@ #ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_GOAWAY_H #define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_GOAWAY_H -#include "src/core/iomgr/iomgr.h" +#include "src/core/iomgr/exec_ctx.h" #include "src/core/transport/chttp2/frame.h" #include <grpc/support/port_platform.h> #include <grpc/support/slice.h> diff --git a/src/core/transport/chttp2/frame_ping.h b/src/core/transport/chttp2/frame_ping.h index fb31147ed4..4224002904 100644 --- a/src/core/transport/chttp2/frame_ping.h +++ b/src/core/transport/chttp2/frame_ping.h @@ -34,8 +34,8 @@ #ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_PING_H #define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_PING_H +#include "src/core/iomgr/exec_ctx.h" #include <grpc/support/slice.h> -#include "src/core/iomgr/iomgr.h" #include "src/core/transport/chttp2/frame.h" typedef struct { diff --git a/src/core/transport/chttp2/frame_rst_stream.h b/src/core/transport/chttp2/frame_rst_stream.h index 05d9e560f4..5d660968ad 100644 --- a/src/core/transport/chttp2/frame_rst_stream.h +++ b/src/core/transport/chttp2/frame_rst_stream.h @@ -36,7 +36,7 @@ #include <grpc/support/slice.h> #include "src/core/transport/chttp2/frame.h" -#include "src/core/iomgr/iomgr.h" +#include "src/core/iomgr/exec_ctx.h" typedef struct { gpr_uint8 byte; diff --git a/src/core/transport/chttp2/frame_settings.h b/src/core/transport/chttp2/frame_settings.h index 7931b8b2ca..f08d527d38 100644 --- a/src/core/transport/chttp2/frame_settings.h +++ b/src/core/transport/chttp2/frame_settings.h @@ -37,7 +37,7 @@ #include <grpc/support/port_platform.h> #include <grpc/support/slice.h> #include "src/core/transport/chttp2/frame.h" -#include "src/core/iomgr/iomgr.h" +#include "src/core/iomgr/exec_ctx.h" typedef enum { GRPC_CHTTP2_SPS_ID0, diff --git a/src/core/transport/chttp2/frame_window_update.h b/src/core/transport/chttp2/frame_window_update.h index 08931044e4..b8fe9095b7 100644 --- a/src/core/transport/chttp2/frame_window_update.h +++ b/src/core/transport/chttp2/frame_window_update.h @@ -34,7 +34,7 @@ #ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_WINDOW_UPDATE_H #define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_WINDOW_UPDATE_H -#include "src/core/iomgr/iomgr.h" +#include "src/core/iomgr/exec_ctx.h" #include <grpc/support/slice.h> #include "src/core/transport/chttp2/frame.h" diff --git a/src/core/transport/chttp2/hpack_parser.h b/src/core/transport/chttp2/hpack_parser.h index 946f8e34ef..0d6d268a06 100644 --- a/src/core/transport/chttp2/hpack_parser.h +++ b/src/core/transport/chttp2/hpack_parser.h @@ -37,7 +37,7 @@ #include <stddef.h> #include <grpc/support/port_platform.h> -#include "src/core/iomgr/iomgr.h" +#include "src/core/iomgr/exec_ctx.h" #include "src/core/transport/chttp2/frame.h" #include "src/core/transport/chttp2/hpack_table.h" #include "src/core/transport/metadata.h" diff --git a/src/core/transport/connectivity_state.h b/src/core/transport/connectivity_state.h index 26f8874fbc..9b4d8da882 100644 --- a/src/core/transport/connectivity_state.h +++ b/src/core/transport/connectivity_state.h @@ -35,7 +35,7 @@ #define GRPC_INTERNAL_CORE_TRANSPORT_CONNECTIVITY_STATE_H #include <grpc/grpc.h> -#include "src/core/iomgr/iomgr.h" +#include "src/core/iomgr/exec_ctx.h" typedef struct grpc_connectivity_state_watcher { /** we keep watchers in a linked list */ |