refactor: cleanup

This commit is contained in:
Folke Lemaitre 2024-06-27 14:43:35 +02:00
parent 37c7163f8d
commit 461552474c
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
4 changed files with 15 additions and 34 deletions

View file

@ -9,7 +9,6 @@ local M = {}
M._queue = {}
M._executor = assert(vim.loop.new_check())
M._running = false
M.SLEEP = "sleep"
---@type Async
M.current = nil
@ -62,9 +61,7 @@ function Async:step()
self.opts.on_error(tostring(res))
end
elseif res then
if res == M.SLEEP then
self.sleeping = true
elseif self.opts.on_yield then
if self.opts.on_yield then
self.opts.on_yield(res)
end
end
@ -130,4 +127,11 @@ function M.wrap(fn, opts)
end
end
---@async
---@param ms number
function M.sleep(ms)
assert(M.current, "Not in an async context")
M.current:sleep(ms)
end
return M