Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

[Wish] uv_loop_t time can option use high resolution time on windows #1437

Closed
DZLiao opened this issue Aug 24, 2014 · 2 comments
Closed

[Wish] uv_loop_t time can option use high resolution time on windows #1437

DZLiao opened this issue Aug 24, 2014 · 2 comments

Comments

@DZLiao
Copy link

DZLiao commented Aug 24, 2014

Some applications need to use high resolution time because the time is sensitive some applications, like video stream. I known that use high resolution time is affect the performance. So maybe it can be optional on windows platform.

First the uv_loop_t add new flag for identify use high resolution time or not. Second, when uv_run() call uv_update_time() check the flag use uv_hrtime() or GetTickCount().

This is my suggestion and flexible for developers.

void uv_update_time(uv_loop_t* loop) {

  // --- Extend begin
  if (loop->use_hrtime == 1) {
    loop->time = uv_hrtime()/1000000;
    return;
  }
  // --- Extend end

  DWORD ticks = GetTickCount();

  /* The assumption is made that LARGE_INTEGER.QuadPart has the same type */
  /* loop->time, which happens to be. Is there any way to assert this? */
  LARGE_INTEGER* time = (LARGE_INTEGER*) &loop->time;

  /* If the timer has wrapped, add 1 to it's high-order dword. */
  /* uv_poll must make sure that the timer can never overflow more than */
  /* once between two subsequent uv_update_time calls. */
  if (ticks < time->LowPart) {
    time->HighPart += 1;
  }
  time->LowPart = ticks;
}
@saghul
Copy link
Contributor

saghul commented Aug 24, 2014

You may want to check this out: #1165

@saghul
Copy link
Contributor

saghul commented Sep 19, 2014

#1165 landed, closing.

@saghul saghul closed this as completed Sep 19, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants