mirror of https://github.com/folke/lazy.nvim.git
perf: suspend when tasks are active
This commit is contained in:
parent
c7ed87f9ca
commit
2f4ac035bc
|
@ -152,12 +152,29 @@ function M.step()
|
|||
table.insert(state._suspended and M._suspended or M._active, state)
|
||||
end
|
||||
|
||||
-- print("step", #M._active, #M._suspended)
|
||||
-- M.debug()
|
||||
if #M._active == 0 then
|
||||
return M._executor:stop()
|
||||
end
|
||||
end
|
||||
|
||||
function M.debug()
|
||||
local lines = {
|
||||
"- active: " .. #M._active,
|
||||
"- suspended: " .. #M._suspended,
|
||||
}
|
||||
for _, async in ipairs(M._active) do
|
||||
local info = debug.getinfo(async._fn)
|
||||
local file = vim.fn.fnamemodify(info.short_src:sub(1), ":~:.")
|
||||
table.insert(lines, ("%s:%d"):format(file, info.linedefined))
|
||||
if #lines > 10 then
|
||||
break
|
||||
end
|
||||
end
|
||||
local msg = table.concat(lines, "\n")
|
||||
M._notif = vim.notify(msg, nil, { replace = M._notif })
|
||||
end
|
||||
|
||||
---@param async Async
|
||||
function M.add(async)
|
||||
table.insert(M._active, async)
|
||||
|
|
|
@ -153,7 +153,9 @@ function Runner:_start()
|
|||
end
|
||||
continue(true)
|
||||
end
|
||||
coroutine.yield()
|
||||
if active > 0 then
|
||||
self._running:suspend()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue