This repository was archived by the owner on May 4, 2018. It is now read-only.
This repository was 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
Description
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;
}
Metadata
Metadata
Assignees
Labels
No labels