aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/microbenchmarks/bm_cq.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 /test/cpp/microbenchmarks/bm_cq.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 'test/cpp/microbenchmarks/bm_cq.cc')
-rw-r--r--test/cpp/microbenchmarks/bm_cq.cc26
1 files changed, 13 insertions, 13 deletions
diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc
index a0c0414f2f..2fd2ba23c0 100644
--- a/test/cpp/microbenchmarks/bm_cq.cc
+++ b/test/cpp/microbenchmarks/bm_cq.cc
@@ -67,7 +67,7 @@ static void BM_CreateDestroyCore(benchmark::State& state) {
}
BENCHMARK(BM_CreateDestroyCore);
-static void DoneWithCompletionOnStack(grpc_exec_ctx* exec_ctx, void* arg,
+static void DoneWithCompletionOnStack(void* arg,
grpc_cq_completion* completion) {}
class DummyTag final : public CompletionQueueTag {
@@ -82,11 +82,11 @@ static void BM_Pass1Cpp(benchmark::State& state) {
while (state.KeepRunning()) {
grpc_cq_completion completion;
DummyTag dummy_tag;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ ExecCtx _local_exec_ctx;
GPR_ASSERT(grpc_cq_begin_op(c_cq, &dummy_tag));
- grpc_cq_end_op(&exec_ctx, c_cq, &dummy_tag, GRPC_ERROR_NONE,
- DoneWithCompletionOnStack, NULL, &completion);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_cq_end_op(c_cq, &dummy_tag, GRPC_ERROR_NONE, DoneWithCompletionOnStack,
+ NULL, &completion);
+ grpc_exec_ctx_finish();
void* tag;
bool ok;
cq.Next(&tag, &ok);
@@ -102,11 +102,11 @@ static void BM_Pass1Core(benchmark::State& state) {
gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
while (state.KeepRunning()) {
grpc_cq_completion completion;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ ExecCtx _local_exec_ctx;
GPR_ASSERT(grpc_cq_begin_op(cq, NULL));
- grpc_cq_end_op(&exec_ctx, cq, NULL, GRPC_ERROR_NONE,
- DoneWithCompletionOnStack, NULL, &completion);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_cq_end_op(cq, NULL, GRPC_ERROR_NONE, DoneWithCompletionOnStack, NULL,
+ &completion);
+ grpc_exec_ctx_finish();
grpc_completion_queue_next(cq, deadline, NULL);
}
grpc_completion_queue_destroy(cq);
@@ -121,11 +121,11 @@ static void BM_Pluck1Core(benchmark::State& state) {
gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
while (state.KeepRunning()) {
grpc_cq_completion completion;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ ExecCtx _local_exec_ctx;
GPR_ASSERT(grpc_cq_begin_op(cq, NULL));
- grpc_cq_end_op(&exec_ctx, cq, NULL, GRPC_ERROR_NONE,
- DoneWithCompletionOnStack, NULL, &completion);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_cq_end_op(cq, NULL, GRPC_ERROR_NONE, DoneWithCompletionOnStack, NULL,
+ &completion);
+ grpc_exec_ctx_finish();
grpc_completion_queue_pluck(cq, NULL, deadline, NULL);
}
grpc_completion_queue_destroy(cq);