diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-11-19 18:39:22 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-11-19 18:39:22 +0800 |
commit | 4fd0c6ec626295844470e544264a1b3607f485b1 (patch) | |
tree | 79dd5fbf8cec047f0b8dfa1a9a97566683fdd72e /script-beta | |
parent | 027d4fc5c0c2dd0457365852a4666c75c535fad3 (diff) | |
download | lua-language-server-4fd0c6ec626295844470e544264a1b3607f485b1.zip |
加个警告
Diffstat (limited to 'script-beta')
-rw-r--r-- | script-beta/await.lua | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/script-beta/await.lua b/script-beta/await.lua index 50406918..d8e2a9ad 100644 --- a/script-beta/await.lua +++ b/script-beta/await.lua @@ -161,6 +161,23 @@ function m.delay() return coroutine.yield() end +local function warnStepTime(passed, waker) + if passed < 1 then + log.warn(('Await step takes [%.3f] sec.'):format(passed)) + return + end + for i = 1, 100 do + local name, v = debug.getupvalue(waker, i) + if not name then + return + end + if name == 'co' then + log.warn(debug.traceback(v, ('[fire]Await step takes [%.3f] sec.'):format(passed))) + return + end + end +end + --- 步进 function m.step() local waker = m.delayQueue[m.delayQueueIndex] @@ -171,7 +188,7 @@ function m.step() waker() local passed = os.clock() - clock if passed > 0.1 then - log.warn(('Await step takes [%.3f] sec.'):format(passed)) + warnStepTime(passed, waker) end return true else |