mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-19 04:46:45 +00:00
perf: automatically suspend the scheduler when all threads are waiting (#1591)
* perf: automatically suspend the scheduler when all threads are waiting * ci: fix ci * test: cleanup
This commit is contained in:
parent
0507e19289
commit
c7ed87f9ca
9 changed files with 81 additions and 54 deletions
|
@ -78,6 +78,7 @@ function Runner:_start()
|
|||
---@type number?
|
||||
local wait_step = nil
|
||||
|
||||
---@async
|
||||
---@param resume? boolean
|
||||
local function continue(resume)
|
||||
active = 0
|
||||
|
@ -114,22 +115,30 @@ function Runner:_start()
|
|||
end
|
||||
local s = state[name]
|
||||
local plugin = self:plugin(name)
|
||||
if s.step == #self._pipeline then
|
||||
-- done
|
||||
s.task = nil
|
||||
plugin._.working = false
|
||||
elseif s.step < #self._pipeline then
|
||||
-- next
|
||||
s.step = s.step + 1
|
||||
local step = self._pipeline[s.step]
|
||||
if step.task == "wait" then
|
||||
while s.step <= #self._pipeline do
|
||||
if s.step == #self._pipeline then
|
||||
-- done
|
||||
s.task = nil
|
||||
plugin._.working = false
|
||||
waiting = waiting + 1
|
||||
wait_step = s.step
|
||||
else
|
||||
s.task = self:queue(plugin, step)
|
||||
plugin._.working = true
|
||||
active = active + 1
|
||||
break
|
||||
elseif s.step < #self._pipeline then
|
||||
-- next
|
||||
s.step = s.step + 1
|
||||
local step = self._pipeline[s.step]
|
||||
if step.task == "wait" then
|
||||
plugin._.working = false
|
||||
waiting = waiting + 1
|
||||
wait_step = s.step
|
||||
break
|
||||
else
|
||||
s.task = self:queue(plugin, step)
|
||||
plugin._.working = true
|
||||
if s.task then
|
||||
active = active + 1
|
||||
s.task:wake(false)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue