Make empth_wakeup() and empth_terminate() wake up empth_sleep(), and
empth_sleep() return whether that happened: [EMPTH_LWP] (lwpWakeupSleep): New, factored out of lwpSelect(). [EMPTH_LWP] (lwpSelect): Use it. [EMPTH_LWP] (lwpWakeup): New. Call lwpWakeupFd() if sleeping in lwpSleepFd(), lwpWakeupSleep() if sleeping in lwpSleepUntil(). [EMPTH_LWP] (lwpTerminate, empth_wakeup): Use it rather than lwpWakeupFd(). [EMPTH_LWP] (lwpWakeupFd): Internal linkage. [EMPTH_LWP] (lwpSleepUntil): Reset member runtime, so that lwpWakeup() can test it reliably. Return how sleep woke up. [EMPTH_LWP] (empth_sleep): Return value of lwpSleepUntil(). [EMPTH_POSIX] (EMPTH_INTR): New. [EMPTH_POSIX] (empth_wakeup): Set state to it. [EMPTH_POSIX] (empth_restorectx): Clear state. [EMPTH_POSIX] (empth_sleep): Don't re-seleep when state is not clear, i.e. thread was woken up prematurely. Return how sleep woke up. [EMPTH_W32] (empth_sleep): Implement by waiting on hThreadEvent with a timeout rather than a straight Sleep(). Return how sleep woke up.
This commit is contained in:
parent
fe2de3d743
commit
cea39829af
7 changed files with 80 additions and 45 deletions
|
@ -181,7 +181,7 @@ void empth_terminate(empth_t *thread);
|
|||
void empth_select(int fd, int flags);
|
||||
|
||||
/*
|
||||
* Awaken THREAD if it is sleeping in empth_select().
|
||||
* Awaken THREAD if it is sleeping in empth_select() or empth_sleep().
|
||||
* Note: This must not awaken threads sleeping in other functions.
|
||||
* Does not yield the processor.
|
||||
*/
|
||||
|
@ -189,9 +189,10 @@ void empth_wakeup(empth_t *thread);
|
|||
|
||||
/*
|
||||
* Put current thread to sleep until the time is UNTIL.
|
||||
* May sleep somehwat longer, but never shorter.
|
||||
* Return 0 if it slept until that time.
|
||||
* Return -1 if woken up early, by empth_wakeup().
|
||||
*/
|
||||
void empth_sleep(time_t until);
|
||||
int empth_sleep(time_t until);
|
||||
|
||||
/*
|
||||
* Wait for signal, return the signal number.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue