(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.
This commit is contained in:
parent
f519de81d6
commit
8d284c5b4a
1 changed files with 5 additions and 26 deletions
|
@ -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
|
* loc_Exit_Handler
|
||||||
*
|
*
|
||||||
|
@ -642,17 +624,14 @@ empth_wakeup(empth_t *a)
|
||||||
void
|
void
|
||||||
empth_sleep(time_t until)
|
empth_sleep(time_t until)
|
||||||
{
|
{
|
||||||
loc_Thread_t *pThread =
|
long lSec;
|
||||||
(loc_Thread_t *)TlsGetValue(loc_GVAR.dwTLSIndex);
|
|
||||||
unsigned long ulSec;
|
|
||||||
|
|
||||||
ulSec = until - time(0);
|
|
||||||
|
|
||||||
loc_debug("going to sleep %ld sec", ulSec);
|
|
||||||
|
|
||||||
loc_BlockThisThread();
|
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.");
|
loc_debug("sleep done. Waiting to run.");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue