mirror of
https://github.com/cuberite/libevent.git
synced 2025-08-04 01:36:23 -04:00
evutil_time: Implements usleep() using wait funtion on Windows
(cherry picked from commit 6412f34f242e9b5b87f0378715baf97ba0bf1a8c)
This commit is contained in:
parent
d9da412658
commit
d42240d1c6
@ -126,8 +126,22 @@ evutil_usleep_(const struct timeval *tv)
|
|||||||
return;
|
return;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
{
|
{
|
||||||
long msec = evutil_tv_to_msec_(tv);
|
__int64 usec;
|
||||||
Sleep((DWORD)msec);
|
LARGE_INTEGER li;
|
||||||
|
HANDLE timer;
|
||||||
|
|
||||||
|
usec = tv->tv_sec * 1000000LL + tv->tv_usec;
|
||||||
|
if (!usec)
|
||||||
|
return;
|
||||||
|
|
||||||
|
li.QuadPart = -10LL * usec;
|
||||||
|
timer = CreateWaitableTimer(NULL, TRUE, NULL);
|
||||||
|
if (!timer)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SetWaitableTimer(timer, &li, 0, NULL, NULL, 0);
|
||||||
|
WaitForSingleObject(timer, INFINITE);
|
||||||
|
CloseHandle(timer);
|
||||||
}
|
}
|
||||||
#elif defined(EVENT__HAVE_NANOSLEEP)
|
#elif defined(EVENT__HAVE_NANOSLEEP)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user