mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-20 13:26:45 +00:00
perf: prevent active waiting in coroutines. suspend/resume instead
This commit is contained in:
parent
79bcc02d17
commit
68cee30cdb
3 changed files with 35 additions and 11 deletions
|
@ -222,6 +222,8 @@ function Task:spawn(cmd, opts)
|
|||
end
|
||||
end
|
||||
|
||||
self._running:suspend()
|
||||
|
||||
local running = true
|
||||
local ret = true
|
||||
---@param output string
|
||||
|
@ -234,6 +236,7 @@ function Task:spawn(cmd, opts)
|
|||
end
|
||||
ret = ok
|
||||
running = false
|
||||
self._running:resume()
|
||||
end
|
||||
|
||||
if headless then
|
||||
|
@ -244,9 +247,8 @@ function Task:spawn(cmd, opts)
|
|||
end
|
||||
end
|
||||
Process.spawn(cmd, opts)
|
||||
while running do
|
||||
coroutine.yield()
|
||||
end
|
||||
coroutine.yield()
|
||||
assert(not running, "process still running?")
|
||||
return ret
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue