aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
diff options
context:
space:
mode:
authorGravatar Sree Kuchibhotla <sreek@google.com>2017-04-11 19:43:07 -0700
committerGravatar Sree Kuchibhotla <sreek@google.com>2017-04-11 19:43:07 -0700
commitd7a1b8f8566746cade81d4931ded1bceafb78412 (patch)
treeecfd8d4858f3c3b52d78944a72a395550efbaad3 /test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
parentfa0f542f67e73d10541ddceb2fd71e6832c585bc (diff)
Functionality complete
Diffstat (limited to 'test/cpp/microbenchmarks/bm_cq_multiple_threads.cc')
-rw-r--r--test/cpp/microbenchmarks/bm_cq_multiple_threads.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
index 9d7f65d292..3362510e5a 100644
--- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
+++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
@@ -79,10 +79,16 @@ static void cq_done_cb(grpc_exec_ctx* exec_ctx, void* done_arg,
gpr_free(cq_completion);
}
-/* Queues a completion tag. ZERO polling overhead */
+/* Queues a completion tag if deadline is > 0.
+ * Does nothing if deadline is 0 (i.e gpr_time_0(GPR_CLOCK_MONOTONIC)) */
static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* ps,
grpc_pollset_worker** worker, gpr_timespec now,
gpr_timespec deadline) {
+ if (gpr_time_cmp(deadline, gpr_time_0(GPR_CLOCK_MONOTONIC)) == 0) {
+ gpr_log(GPR_ERROR, "no-op");
+ return GRPC_ERROR_NONE;
+ }
+
gpr_mu_unlock(&ps->mu);
grpc_cq_begin_op(g_cq, g_tag);
grpc_cq_end_op(exec_ctx, g_cq, g_tag, GRPC_ERROR_NONE, cq_done_cb, NULL,
@@ -113,6 +119,14 @@ static void setup() {
static void teardown() {
grpc_completion_queue_shutdown(g_cq);
+
+ /* Drain any events */
+ gpr_timespec deadline = gpr_time_0(GPR_CLOCK_MONOTONIC);
+ while (grpc_completion_queue_next(g_cq, deadline, NULL).type !=
+ GRPC_QUEUE_SHUTDOWN) {
+ /* Do nothing */
+ }
+
grpc_completion_queue_destroy(g_cq);
}