nbio(windows): handle queued work in the tick that was woken for it; nbio(tests): let wake_up tolerate a tick that returns without progress

This commit is contained in:
kalsprite
2026-08-21 09:18:57 -07:00
parent 6e690afaf1
commit d2da33235d
2 changed files with 19 additions and 2 deletions

View File

@@ -241,6 +241,20 @@ __tick :: proc(l: ^Event_Loop, timeout: time.Duration) -> (err: General_Error) {
actual_timeout = 0
}
// A wake, or another loop routing a completion to us, can leave work queued.
// Handle it here instead of waiting for the caller to tick again.
for {
op := (^Operation)(mpsc_dequeue(&l.queue))
if op == nil { break }
_exec(op)
}
for {
op := (^Operation)(mpsc_dequeue(&l.completed_oob))
if op == nil { break }
handle_completed(op)
}
return nil
compute_timeout :: proc(l: ^Event_Loop, timeout: time.Duration, next_timeout: Maybe(time.Duration)) -> win.DWORD {

View File

@@ -244,8 +244,11 @@ wake_up :: proc(t: ^testing.T) {
}, context)
defer thread.destroy(thr)
// Should block forever until the thread calling wake_up will make it return.
ev(t, nbio.tick(), nil)
// A tick can return without progress; loop until the wake is observed.
// A lost wake would block here forever and trip the fail timeout.
for !hit {
ev(t, nbio.tick(), nil)
}
e(t, hit)
nbio.remove(accept)