aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/surface/channel_ping.cc
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/surface/channel_ping.cc
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/surface/channel_ping.cc')
-rw-r--r--src/core/lib/surface/channel_ping.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/core/lib/surface/channel_ping.cc b/src/core/lib/surface/channel_ping.cc
index f45b568958..5d41b8e9e4 100644
--- a/src/core/lib/surface/channel_ping.cc
+++ b/src/core/lib/surface/channel_ping.cc
@@ -33,15 +33,14 @@ typedef struct {
grpc_cq_completion completion_storage;
} ping_result;
-static void ping_destroy(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_cq_completion *storage) {
+static void ping_destroy(void *arg, grpc_cq_completion *storage) {
gpr_free(arg);
}
-static void ping_done(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
+static void ping_done(void *arg, grpc_error *error) {
ping_result *pr = (ping_result *)arg;
- grpc_cq_end_op(exec_ctx, pr->cq, pr->tag, GRPC_ERROR_REF(error), ping_destroy,
- pr, &pr->completion_storage);
+ grpc_cq_end_op(pr->cq, pr->tag, GRPC_ERROR_REF(error), ping_destroy, pr,
+ &pr->completion_storage);
}
void grpc_channel_ping(grpc_channel *channel, grpc_completion_queue *cq,
@@ -52,7 +51,7 @@ void grpc_channel_ping(grpc_channel *channel, grpc_completion_queue *cq,
ping_result *pr = (ping_result *)gpr_malloc(sizeof(*pr));
grpc_channel_element *top_elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ ExecCtx _local_exec_ctx;
GPR_ASSERT(reserved == NULL);
pr->tag = tag;
pr->cq = cq;
@@ -60,6 +59,6 @@ void grpc_channel_ping(grpc_channel *channel, grpc_completion_queue *cq,
op->send_ping = &pr->closure;
op->bind_pollset = grpc_cq_pollset(cq);
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
- top_elem->filter->start_transport_op(&exec_ctx, top_elem, op);
- grpc_exec_ctx_finish(&exec_ctx);
+ top_elem->filter->start_transport_op(top_elem, op);
+ grpc_exec_ctx_finish();
}