mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 02:11:36 -04:00
host_time: bound the Windows timer wait
Even with per-thread timers, an INFINITE wait turns any missed signal into an indefinitely parked thread. Wait at most the requested sleep plus 2 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -86,8 +86,10 @@ void psx_host_sleep_micros(unsigned usec)
|
||||
if (hundred_ns >= 0)
|
||||
hundred_ns = -1LL;
|
||||
due.QuadPart = hundred_ns;
|
||||
if (SetWaitableTimer(timer, &due, 0, NULL, NULL, FALSE) &&
|
||||
WaitForSingleObject(timer, INFINITE) == WAIT_OBJECT_0) {
|
||||
/* Bounded: a missed signal costs at most the sleep plus 2 ms, never
|
||||
* an indefinitely parked thread. */
|
||||
if (SetWaitableTimer(timer, &due, 0, NULL, NULL, FALSE)) {
|
||||
(void)WaitForSingleObject(timer, (DWORD)(usec / 1000u) + 2u);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user