Ensure the empth_sleep() always yields for WIN32
The WIN32 version did not block when the sleep was already reached by the time empth_sleep() did the time remaining calculation. The other versions of empth_sleep() do always yield.
This commit is contained in:
parent
d46b0b727d
commit
af2a87e490
1 changed files with 4 additions and 3 deletions
|
@ -613,11 +613,11 @@ empth_wakeup(empth_t *pThread)
|
||||||
int
|
int
|
||||||
empth_sleep(time_t until)
|
empth_sleep(time_t until)
|
||||||
{
|
{
|
||||||
long lSec;
|
long lSec = until - time(0) > 0 ? until - time(0) : 0;
|
||||||
empth_t *pThread = TlsGetValue(dwTLSIndex);
|
empth_t *pThread = TlsGetValue(dwTLSIndex);
|
||||||
int iReturn = 0;
|
int iReturn = 0;
|
||||||
|
|
||||||
while (!iReturn && ((lSec = until - time(0)) > 0)) {
|
do {
|
||||||
loc_BlockThisThread();
|
loc_BlockThisThread();
|
||||||
loc_debug("going to sleep %ld sec", lSec);
|
loc_debug("going to sleep %ld sec", lSec);
|
||||||
|
|
||||||
|
@ -627,7 +627,8 @@ empth_sleep(time_t until)
|
||||||
|
|
||||||
loc_debug("sleep done. Waiting to run.");
|
loc_debug("sleep done. Waiting to run.");
|
||||||
loc_RunThisThread(NULL);
|
loc_RunThisThread(NULL);
|
||||||
}
|
} while (!iReturn && ((lSec = until - time(0)) > 0));
|
||||||
|
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue