Implement gpr_sleep_until for Windows.

pull/1232/head
Craig Tiller 10 years ago
parent c3d5f16d75
commit 818efa6741
  1. 20
      src/core/support/time_win32.c

@ -39,6 +39,7 @@
#include <grpc/support/time.h>
#include <sys/timeb.h>
#include <windows.h>
gpr_timespec gpr_now(void) {
gpr_timespec now_tv;
@ -49,4 +50,23 @@ gpr_timespec gpr_now(void) {
return now_tv;
}
void gpr_sleep_until(gpr_timespec until) {
gpr_timespec now;
gpr_timespec delta;
DWORD sleep_millis;
for (;;) {
/* We could simplify by using clock_nanosleep instead, but it might be
* slightly less portable. */
now = gpr_now();
if (gpr_time_cmp(until, now) <= 0) {
return;
}
delta = gpr_time_sub(until, now);
sleep_millis = delta.tv_sec * GPR_MS_PER_SEC + delta.tv_nsec / GPR_NS_PER_MS;
Sleep(sleep_millis);
}
}
#endif /* GPR_WIN32 */

Loading…
Cancel
Save