[modified] minor async refactoring

[fixed] missing arguments beyond 1 for async calls
This commit is contained in:
Max Cahill 2020-05-19 22:11:38 +10:00
parent 700c7bc957
commit 77327aa852

View File

@ -28,19 +28,14 @@ end
--add a task to the kernel --add a task to the kernel
function async:call(f, args, callback, error_callback) function async:call(f, args, callback, error_callback)
table.insert(self.tasks, { self:add(coroutine.create(f), args, callback, error_callback)
coroutine.create(f),
args or false,
callback or false,
error_callback or false,
})
end end
--add an already-existing coroutine to the kernel --add an already-existing coroutine to the kernel
function async:add(co, args, callback, error_callback) function async:add(co, args, callback, error_callback)
table.insert(self.tasks, { table.insert(self.tasks, {
co, co,
args or false, args or {},
callback or false, callback or false,
error_callback or false, error_callback or false,
}) })
@ -64,7 +59,7 @@ function async:update()
--(using unpack because coroutine is also nyi and it's core to this async model) --(using unpack because coroutine is also nyi and it's core to this async model)
local co, args, cb, error_cb = unpack(td) local co, args, cb, error_cb = unpack(td)
--(8 temps rather than table churn capturing varargs) --(8 temps rather than table churn capturing varargs)
local success, a, b, c, d, e, f, g, h = coroutine.resume(co, args and unpack(args)) local success, a, b, c, d, e, f, g, h = coroutine.resume(co, unpack(args))
--error? --error?
if not success then if not success then
if error_cb then if error_cb then