Report sooner

pull/6160/head
Craig Tiller 9 years ago
parent 849155d03a
commit 3f72df9999
  1. 12
      src/core/lib/iomgr/timer.c

@ -83,6 +83,7 @@ static gpr_timespec compute_min_deadline(shard_type *shard) {
void grpc_timer_list_init(gpr_timespec now) {
uint32_t i;
g_initialized = true;
gpr_mu_init(&g_mu);
gpr_mu_init(&g_checker_mu);
g_clock_type = now.clock_type;
@ -111,6 +112,7 @@ void grpc_timer_list_shutdown(grpc_exec_ctx *exec_ctx) {
}
gpr_mu_destroy(&g_mu);
gpr_mu_destroy(&g_checker_mu);
g_initialized = false;
}
/* This is a cheap, but good enough, pointer hash for sharding the tasks: */
@ -180,6 +182,16 @@ void grpc_timer_init(grpc_exec_ctx *exec_ctx, grpc_timer *timer,
timer->deadline = deadline;
timer->triggered = 0;
if (!g_initialized) {
grpc_exec_ctx_enqueue(exec_ctx, &timer->closure, false);
return;
}
if (gpr_time_cmp(deadline, now) <= 0) {
grpc_exec_ctx_enqueue(exec_ctx, &timer->closure, true);
return;
}
/* TODO(ctiller): check deadline expired */
gpr_mu_lock(&shard->mu);

Loading…
Cancel
Save