From 8d284c5b4abd75e6515826188d70f6268de8ef93 Mon Sep 17 00:00:00 2001 From: Ron Koenderink Date: Sat, 25 Jun 2005 16:49:20 +0000 Subject: [PATCH] (empth_sleep) [_WIN32]: If the sleep returns early, go back to sleep. Short sleeps can cause double-updates and other trouble. [_WIN32] (loc_SleepThisThread): Not used, removed. --- src/lib/empthread/ntthread.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/src/lib/empthread/ntthread.c b/src/lib/empthread/ntthread.c index b870723bd..c74758a7e 100644 --- a/src/lib/empthread/ntthread.c +++ b/src/lib/empthread/ntthread.c @@ -263,24 +263,6 @@ loc_BlockThisThread() } } - -/************************ - * loc_SleepThisThread - */ -static void -loc_SleepThisThread(unsigned long ulMillisecs) -{ - loc_Thread_t *pThread = - (loc_Thread_t *)TlsGetValue(loc_GVAR.dwTLSIndex); - - /* Make sure the event thread is clean. */ - ResetEvent(pThread->hThreadEvent); - - /* Get the MUTEX semaphore, wait the number of MS */ - WaitForSingleObject(pThread->hThreadEvent, ulMillisecs); -} - - /************************ * loc_Exit_Handler * @@ -642,17 +624,14 @@ empth_wakeup(empth_t *a) void empth_sleep(time_t until) { - loc_Thread_t *pThread = - (loc_Thread_t *)TlsGetValue(loc_GVAR.dwTLSIndex); - unsigned long ulSec; - - ulSec = until - time(0); - - loc_debug("going to sleep %ld sec", ulSec); + long lSec; loc_BlockThisThread(); - WaitForSingleObject(pThread->hThreadEvent, (ulSec * 1000)); + while ((lSec = until - time(0)) > 0) { + loc_debug("going to sleep %ld sec", lSec); + Sleep(lSec * 1000L); + } loc_debug("sleep done. Waiting to run."); -- 2.43.0