diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-12-12 18:02:35 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-12-12 18:02:35 +0800 |
commit | d7ccb096afa721ce99cadbbefd47ab8d92238037 (patch) | |
tree | 309a1b2413ef4e4ea723db2afce53a589c0b9951 /script-beta/await.lua | |
parent | e907e03ecaedd600ceeaa83cf4c3176a40988f74 (diff) | |
download | lua-language-server-d7ccb096afa721ce99cadbbefd47ab8d92238037.zip |
去掉一些不必要的日志
Diffstat (limited to 'script-beta/await.lua')
-rw-r--r-- | script-beta/await.lua | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/script-beta/await.lua b/script-beta/await.lua index 30cbf993..008217c8 100644 --- a/script-beta/await.lua +++ b/script-beta/await.lua @@ -5,6 +5,7 @@ local m = {} m.type = 'await' m.coTracker = setmetatable({}, { __mode = 'k' }) +m.coPriority = setmetatable({}, { __mode = 'k' }) m.delayQueue = {} m.delayQueueIndex = 1 @@ -69,6 +70,10 @@ function m.delay(getVersion) return end local co = coroutine.running() + -- TODO + if m.coPriority[co] then + return + end local version = getVersion and getVersion() m.delayQueue[#m.delayQueue+1] = function () if version == (getVersion and getVersion()) then @@ -80,7 +85,7 @@ function m.delay(getVersion) return coroutine.yield() end -local function buildInfo(waker) +local function getCo(waker) local co for i = 1, 100 do local n, v = debug.getupvalue(waker, i) @@ -92,10 +97,7 @@ local function buildInfo(waker) break end end - if not co then - return nil - end - return debug.traceback(co) + return co end --- 步进 @@ -108,7 +110,7 @@ function m.step() waker() local passed = os.clock() - clock if passed > 0.1 then - log.warn(('Await step takes [%.3f] sec.\n%s'):format(passed, buildInfo(waker))) + log.debug(('Await step takes [%.3f] sec.'):format(passed)) end return true else @@ -118,4 +120,8 @@ function m.step() end end +function m.setPriority(n) + m.coPriority[coroutine.running()] = n +end + return m |