diff options
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 |
