mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-19 12:56:46 +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
|
@ -232,13 +232,9 @@ end
|
|||
---@async
|
||||
---@param ms number
|
||||
function M.sleep(ms)
|
||||
local continue = false
|
||||
vim.defer_fn(function()
|
||||
continue = true
|
||||
end, ms)
|
||||
while not continue do
|
||||
coroutine.yield()
|
||||
end
|
||||
local async = require("lazy.async").current
|
||||
assert(async, "Not in an async context")
|
||||
async:sleep(ms)
|
||||
end
|
||||
|
||||
function M._dump(value, result)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue