diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-08-15 19:36:49 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-08-15 19:36:49 +0800 |
commit | d20d2d2dadc30e518475908afa5d60dcc02554da (patch) | |
tree | fed347822f9fe4c193eb83f312d75f66095a6ffe /script-beta/await.lua | |
parent | 390108b1bd06cc2bcd32e1ad7d62a76eccbd30cc (diff) | |
download | lua-language-server-d20d2d2dadc30e518475908afa5d60dcc02554da.zip |
await.wait 也要使用延迟检查器
Diffstat (limited to 'script-beta/await.lua')
-rw-r--r-- | script-beta/await.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/script-beta/await.lua b/script-beta/await.lua index 78f40e66..ff45a141 100644 --- a/script-beta/await.lua +++ b/script-beta/await.lua @@ -31,6 +31,7 @@ function m.create(callback, ...) return m.checkResult(co, coroutine.resume(co, ...)) end +--- 对当前任务设置一个延迟检查器,当延迟前后检查器的返回值不同时,放弃此任务 function m.setDelayer(callback) local co = coroutine.running() m.coDelayer[co] = callback @@ -47,8 +48,11 @@ function m.sleep(time, getVersion) end local version = getVersion and getVersion() local co = coroutine.running() + local delayer = m.coDelayer[co] + local dVersion = delayer and delayer() timer.wait(time, function () - if version == (getVersion and getVersion()) then + if version == (getVersion and getVersion()) + and dVersion == (delayer and delayer()) then return m.checkResult(co, coroutine.resume(co)) else coroutine.close(co) |