diff options
-rw-r--r-- | src/core/lib/iomgr/exec_ctx.cc | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/core/lib/iomgr/exec_ctx.cc b/src/core/lib/iomgr/exec_ctx.cc index c3182dca3a..efa344fad1 100644 --- a/src/core/lib/iomgr/exec_ctx.cc +++ b/src/core/lib/iomgr/exec_ctx.cc @@ -118,7 +118,8 @@ static time_atm_pair // gpr_clock_type static grpc_millis g_last_start_time_update; -static gpr_timespec timespec_from_time_atm_pair(const time_atm_pair* src, gpr_clock_type clock_type) { +static gpr_timespec timespec_from_time_atm_pair(const time_atm_pair* src, + gpr_clock_type clock_type) { gpr_timespec time; time.tv_nsec = (int32_t)gpr_atm_no_barrier_load(&src->tv_nsec); time.tv_sec = (int64_t)gpr_atm_no_barrier_load(&src->tv_sec); @@ -142,7 +143,8 @@ void grpc_exec_ctx_global_init(void) { void grpc_exec_ctx_global_shutdown(void) {} static gpr_atm timespec_to_atm_round_down(gpr_timespec ts) { - gpr_timespec start_time = timespec_from_time_atm_pair(&g_start_time[ts.clock_type], ts.clock_type); + gpr_timespec start_time = + timespec_from_time_atm_pair(&g_start_time[ts.clock_type], ts.clock_type); ts = gpr_time_sub(ts, start_time); double x = GPR_MS_PER_SEC * (double)ts.tv_sec + (double)ts.tv_nsec / GPR_NS_PER_MS; @@ -152,7 +154,8 @@ static gpr_atm timespec_to_atm_round_down(gpr_timespec ts) { } static gpr_atm timespec_to_atm_round_up(gpr_timespec ts) { - gpr_timespec start_time = timespec_from_time_atm_pair(&g_start_time[ts.clock_type], ts.clock_type); + gpr_timespec start_time = + timespec_from_time_atm_pair(&g_start_time[ts.clock_type], ts.clock_type); ts = gpr_time_sub(ts, start_time); double x = GPR_MS_PER_SEC * (double)ts.tv_sec + (double)ts.tv_nsec / GPR_NS_PER_MS + @@ -188,9 +191,9 @@ gpr_timespec grpc_millis_to_timespec(grpc_millis millis, if (clock_type == GPR_TIMESPAN) { return gpr_time_from_millis(millis, GPR_TIMESPAN); } - gpr_timespec start_time = timespec_from_time_atm_pair(&g_start_time[clock_type], clock_type); - return gpr_time_add(start_time, - gpr_time_from_millis(millis, GPR_TIMESPAN)); + gpr_timespec start_time = + timespec_from_time_atm_pair(&g_start_time[clock_type], clock_type); + return gpr_time_add(start_time, gpr_time_from_millis(millis, GPR_TIMESPAN)); } grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec ts) { @@ -203,16 +206,19 @@ grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec ts) { void grpc_exec_ctx_maybe_update_start_time(grpc_exec_ctx* exec_ctx) { grpc_millis now = grpc_exec_ctx_now(exec_ctx); - grpc_millis last_start_time_update = gpr_atm_no_barrier_load(&g_last_start_time_update); + grpc_millis last_start_time_update = + gpr_atm_no_barrier_load(&g_last_start_time_update); if (now > last_start_time_update && now - last_start_time_update > GRPC_START_TIME_UPDATE_INTERVAL) { gpr_atm_no_barrier_store(&g_last_start_time_update, now); gpr_timespec real_now = gpr_now(GPR_CLOCK_REALTIME); - gpr_timespec real_start_time = gpr_time_sub(real_now, gpr_time_from_millis(now, GPR_TIMESPAN)); + gpr_timespec real_start_time = + gpr_time_sub(real_now, gpr_time_from_millis(now, GPR_TIMESPAN)); time_atm_pair_store(&g_start_time[GPR_CLOCK_REALTIME], real_start_time); if (GRPC_TRACER_ON(grpc_timer_check_trace)) { - gpr_log(GPR_DEBUG, "Update realtime clock start time: %" PRId64 "s %dns", real_start_time.tv_sec, real_start_time.tv_nsec); + gpr_log(GPR_DEBUG, "Update realtime clock start time: %" PRId64 "s %dns", + real_start_time.tv_sec, real_start_time.tv_nsec); } } } |