perf: prevent active waiting in coroutines. suspend/resume instead

This commit is contained in:
Folke Lemaitre 2024-06-27 13:06:39 +02:00
parent 79bcc02d17
commit 68cee30cdb
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
3 changed files with 35 additions and 11 deletions

View file

@ -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)