aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/surface
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2016-02-22 17:41:41 -0800
committerGravatar David Garcia Quintas <dgq@google.com>2016-02-22 17:41:41 -0800
commitef02fb9d6ffa9b0df265a100cdd6262515c6029d (patch)
tree7f14edf5e605112ae8b984843ef865e8735216da /src/core/surface
parent10e269897f3f664edb22befc646522b18e2d3586 (diff)
parent349bba9179f27a058470de3c2fd2ac6c9ccb80b5 (diff)
Merge branch 'master' of github.com:grpc/grpc into alarm_cpp
Diffstat (limited to 'src/core/surface')
-rw-r--r--src/core/surface/completion_queue.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/core/surface/completion_queue.c b/src/core/surface/completion_queue.c
index 75298eb795..0a80680f02 100644
--- a/src/core/surface/completion_queue.c
+++ b/src/core/surface/completion_queue.c
@@ -323,7 +323,20 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc,
break;
}
first_loop = 0;
- grpc_pollset_work(&exec_ctx, &cc->pollset, &worker, now, deadline);
+ /* Check alarms - these are a global resource so we just ping
+ each time through on every pollset.
+ May update deadline to ensure timely wakeups.
+ TODO(ctiller): can this work be localized? */
+ gpr_timespec iteration_deadline = deadline;
+ if (grpc_timer_check(&exec_ctx, now, &iteration_deadline)) {
+ GPR_TIMER_MARK("alarm_triggered", 0);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&cc->pollset));
+ grpc_exec_ctx_flush(&exec_ctx);
+ gpr_mu_lock(GRPC_POLLSET_MU(&cc->pollset));
+ } else {
+ grpc_pollset_work(&exec_ctx, &cc->pollset, &worker, now,
+ iteration_deadline);
+ }
}
GRPC_SURFACE_TRACE_RETURNED_EVENT(cc, &ret);
GRPC_CQ_INTERNAL_UNREF(cc, "next");
@@ -427,7 +440,20 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag,
break;
}
first_loop = 0;
- grpc_pollset_work(&exec_ctx, &cc->pollset, &worker, now, deadline);
+ /* Check alarms - these are a global resource so we just ping
+ each time through on every pollset.
+ May update deadline to ensure timely wakeups.
+ TODO(ctiller): can this work be localized? */
+ gpr_timespec iteration_deadline = deadline;
+ if (grpc_timer_check(&exec_ctx, now, &iteration_deadline)) {
+ GPR_TIMER_MARK("alarm_triggered", 0);
+ gpr_mu_unlock(GRPC_POLLSET_MU(&cc->pollset));
+ grpc_exec_ctx_flush(&exec_ctx);
+ gpr_mu_lock(GRPC_POLLSET_MU(&cc->pollset));
+ } else {
+ grpc_pollset_work(&exec_ctx, &cc->pollset, &worker, now,
+ iteration_deadline);
+ }
del_plucker(cc, tag, &worker);
}
done: