From 77327aa8526877a405a1d45d23110c9482c04f3f Mon Sep 17 00:00:00 2001 From: Max Cahill <1bardesign@gmail.com> Date: Tue, 19 May 2020 22:11:38 +1000 Subject: [PATCH] [modified] minor async refactoring [fixed] missing arguments beyond 1 for async calls --- async.lua | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/async.lua b/async.lua index 6cdd216..cb1e774 100644 --- a/async.lua +++ b/async.lua @@ -28,19 +28,14 @@ end --add a task to the kernel function async:call(f, args, callback, error_callback) - table.insert(self.tasks, { - coroutine.create(f), - args or false, - callback or false, - error_callback or false, - }) + self:add(coroutine.create(f), args, callback, error_callback) end --add an already-existing coroutine to the kernel function async:add(co, args, callback, error_callback) table.insert(self.tasks, { co, - args or false, + args or {}, 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) local co, args, cb, error_cb = unpack(td) --(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? if not success then if error_cb then