mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-26 06:51:34 +00:00
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:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user