diff options
Diffstat (limited to 'server-beta/src/await.lua')
-rw-r--r-- | server-beta/src/await.lua | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/server-beta/src/await.lua b/server-beta/src/await.lua index 4187f4b4..92db7f73 100644 --- a/server-beta/src/await.lua +++ b/server-beta/src/await.lua @@ -62,7 +62,7 @@ function m.wait(callback, ...) end --- 延迟 -function m.delay(...) +function m.delay(getVersion) local co, main = coroutine.running() if main then if m.errorHandle then @@ -70,16 +70,22 @@ function m.delay(...) end return end - m.delayQueue[#m.delayQueue+1] = function (...) - return m.checkResult(co, coroutine.resume(co, ...)) + local version = getVersion and getVersion() + m.delayQueue[#m.delayQueue+1] = function () + if version == (getVersion and getVersion()) then + return m.checkResult(co, coroutine.resume(co)) + else + coroutine.close(co) + end end - return coroutine.yield(...) + return coroutine.yield() end --- 步进 function m.step() local waker = m.delayQueue[m.delayQueueIndex] if waker then + m.delayQueue[m.delayQueueIndex] = false m.delayQueueIndex = m.delayQueueIndex + 1 waker() return true |