diff options
| author | ruki <[email protected]> | 2026-08-23 14:59:19 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-08-23 14:59:19 +0800 |
| commit | 7ddecb012e558dacc0c9aae762c43c3c863a372c (patch) | |
| tree | fa7d7a3795f4f6bf6be8dcd4f805f471e68de191 /xmake/core/base/scheduler.lua | |
| parent | deaabcd162bebe9312201bcaac48404fd8a1925a (diff) | |
fix wait 0wait
Diffstat (limited to 'xmake/core/base/scheduler.lua')
| -rw-r--r-- | xmake/core/base/scheduler.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/xmake/core/base/scheduler.lua b/xmake/core/base/scheduler.lua index 4ae8d74e0..f936f1d8f 100644 --- a/xmake/core/base/scheduler.lua +++ b/xmake/core/base/scheduler.lua @@ -982,6 +982,15 @@ function scheduler:poller_wait(obj, events, timeout) end end + -- no events yet? return immediately if timeout is zero + -- + -- @note we save the waiting events, so the poller caches the events when they + -- arrive and the next wait returns them immediately + if timeout == 0 then + pollerdata.poller_events_wait = events_wait + return 0 + end + -- register timeout task to timer local timer_task = nil if timeout > 0 then @@ -1053,6 +1062,14 @@ function scheduler:poller_waitproc(obj, timeout) return -1, errors end + -- has not exited yet? return immediately if timeout is zero + -- + -- @note we have inserted it into the poller, so its exit status is still saved + -- as a pending status when it exits later, and the next wait returns it immediately + if timeout == 0 then + return 0 + end + -- register timeout task to timer local timer_task = nil if timeout > 0 then @@ -1123,6 +1140,14 @@ function scheduler:poller_waitfs(obj, timeout) return -1, errors end + -- no event yet? return immediately if timeout is zero + -- + -- @note we have inserted it into the poller, so the next event is still saved + -- as a pending status when it arrives, and the next wait returns it immediately + if timeout == 0 then + return 0 + end + -- register timeout task to timer local timer_task = nil if timeout > 0 then |
