From 0a7468a537f3cc22160247ef88968c8c2d5af118 Mon Sep 17 00:00:00 2001 From: Alistair Veitch Date: Fri, 5 Feb 2016 13:13:13 -0800 Subject: Add timespan support for win32 gpr_cv_wait. --- include/grpc/impl/codegen/sync.h | 3 ++- src/core/support/sync_win32.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/grpc/impl/codegen/sync.h b/include/grpc/impl/codegen/sync.h index 7086b5d371..04ff0dc5bf 100644 --- a/include/grpc/impl/codegen/sync.h +++ b/include/grpc/impl/codegen/sync.h @@ -115,7 +115,8 @@ GPR_API void gpr_cv_destroy(gpr_cv *cv); /* Atomically release *mu and wait on *cv. When the calling thread is woken from *cv or the deadline abs_deadline is exceeded, execute gpr_mu_lock(mu) and return whether the deadline was exceeded. Use - abs_deadline==gpr_inf_future for no deadline. May return even when not + abs_deadline==gpr_inf_future for no deadline. abs_deadline can be either + an absolute deadline, or a GPR_TIMESPAN. May return even when not woken explicitly. Requires: *mu and *cv initialized; the calling thread holds an exclusive lock on *mu. */ GPR_API int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline); diff --git a/src/core/support/sync_win32.c b/src/core/support/sync_win32.c index 84d412a75f..41998ebcb6 100644 --- a/src/core/support/sync_win32.c +++ b/src/core/support/sync_win32.c @@ -87,6 +87,7 @@ int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline) { 0) { SleepConditionVariableCS(cv, &mu->cs, INFINITE); } else { + abs_deadline = gpr_convert_clock_type(abs_deadline, GPR_CLOCK_REALTIME); gpr_timespec now = gpr_now(abs_deadline.clock_type); int64_t now_ms = (int64_t)now.tv_sec * 1000 + now.tv_nsec / 1000000; int64_t deadline_ms = -- cgit v1.2.3