aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/iomgr/closure.h
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2017-10-13 16:07:13 -0700
committerGravatar Yash Tibrewal <yashkt@google.com>2017-10-18 17:12:19 -0700
commit0ee7574732a06e8cace4e099a678f4bd5dbff679 (patch)
treee43d5de442fdcc3d39cd5af687f319fa39612d3f /src/core/lib/iomgr/closure.h
parent6bf5f833efe2cb9e2ecc14358dd9699cd5d05263 (diff)
Removing instances of exec_ctx being passed around in functions in
src/core. exec_ctx is now a thread_local pointer of type ExecCtx instead of grpc_exec_ctx which is initialized whenever ExecCtx is instantiated. ExecCtx also keeps track of the previous exec_ctx so that nesting of exec_ctx is allowed. This means that there is only one exec_ctx being used at any time. Also, grpc_exec_ctx_finish is called in the destructor of the object, and the previous exec_ctx is restored to avoid breaking current functionality. The code still explicitly calls grpc_exec_ctx_finish because removing all such instances causes the code to break.
Diffstat (limited to 'src/core/lib/iomgr/closure.h')
-rw-r--r--src/core/lib/iomgr/closure.h34
1 files changed, 13 insertions, 21 deletions
diff --git a/src/core/lib/iomgr/closure.h b/src/core/lib/iomgr/closure.h
index cd32a4ba38..8b59b17dfb 100644
--- a/src/core/lib/iomgr/closure.h
+++ b/src/core/lib/iomgr/closure.h
@@ -49,18 +49,15 @@ typedef struct grpc_closure_list {
* describing what went wrong.
* Error contract: it is not the cb's job to unref this error;
* the closure scheduler will do that after the cb returns */
-typedef void (*grpc_iomgr_cb_func)(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error);
+typedef void (*grpc_iomgr_cb_func)(void *arg, grpc_error *error);
typedef struct grpc_closure_scheduler grpc_closure_scheduler;
typedef struct grpc_closure_scheduler_vtable {
/* NOTE: for all these functions, closure->scheduler == the scheduler that was
used to find this vtable */
- void (*run)(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_error *error);
- void (*sched)(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_error *error);
+ void (*run)(grpc_closure *closure, grpc_error *error);
+ void (*sched)(grpc_closure *closure, grpc_error *error);
const char *name;
} grpc_closure_scheduler_vtable;
@@ -164,26 +161,22 @@ bool grpc_closure_list_empty(grpc_closure_list list);
#ifndef NDEBUG
void grpc_closure_run(const char *file, int line, grpc_exec_ctx *exec_ctx,
grpc_closure *closure, grpc_error *error);
-#define GRPC_CLOSURE_RUN(exec_ctx, closure, error) \
+#define GRPC_CLOSURE_RUN(closure, error) \
grpc_closure_run(__FILE__, __LINE__, exec_ctx, closure, error)
#else
-void grpc_closure_run(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_error *error);
-#define GRPC_CLOSURE_RUN(exec_ctx, closure, error) \
- grpc_closure_run(exec_ctx, closure, error)
+void grpc_closure_run(grpc_closure *closure, grpc_error *error);
+#define GRPC_CLOSURE_RUN(closure, error) grpc_closure_run(closure, error)
#endif
/** Schedule a closure to be run. Does not need to be run from a safe point. */
#ifndef NDEBUG
void grpc_closure_sched(const char *file, int line, grpc_exec_ctx *exec_ctx,
grpc_closure *closure, grpc_error *error);
-#define GRPC_CLOSURE_SCHED(exec_ctx, closure, error) \
+#define GRPC_CLOSURE_SCHED(closure, error) \
grpc_closure_sched(__FILE__, __LINE__, exec_ctx, closure, error)
#else
-void grpc_closure_sched(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_error *error);
-#define GRPC_CLOSURE_SCHED(exec_ctx, closure, error) \
- grpc_closure_sched(exec_ctx, closure, error)
+void grpc_closure_sched(grpc_closure *closure, grpc_error *error);
+#define GRPC_CLOSURE_SCHED(closure, error) grpc_closure_sched(closure, error)
#endif
/** Schedule all closures in a list to be run. Does not need to be run from a
@@ -192,13 +185,12 @@ void grpc_closure_sched(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
void grpc_closure_list_sched(const char *file, int line,
grpc_exec_ctx *exec_ctx,
grpc_closure_list *closure_list);
-#define GRPC_CLOSURE_LIST_SCHED(exec_ctx, closure_list) \
+#define GRPC_CLOSURE_LIST_SCHED(closure_list) \
grpc_closure_list_sched(__FILE__, __LINE__, exec_ctx, closure_list)
#else
-void grpc_closure_list_sched(grpc_exec_ctx *exec_ctx,
- grpc_closure_list *closure_list);
-#define GRPC_CLOSURE_LIST_SCHED(exec_ctx, closure_list) \
- grpc_closure_list_sched(exec_ctx, closure_list)
+void grpc_closure_list_sched(grpc_closure_list *closure_list);
+#define GRPC_CLOSURE_LIST_SCHED(closure_list) \
+ grpc_closure_list_sched(closure_list)
#endif
#ifdef __cplusplus