From 6e3a285f9707f65618bde26cee3e1e0bc4c70996 Mon Sep 17 00:00:00 2001 From: Max Cahill <1bardesign@gmail.com> Date: Tue, 8 Aug 2023 12:57:35 +1000 Subject: [PATCH] fixed reliance on tablex exported to table in async:remove --- async.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/async.lua b/async.lua index f55fcc5..bb684a2 100644 --- a/async.lua +++ b/async.lua @@ -18,6 +18,7 @@ local path = (...):gsub("async", "") local assert = require(path .. "assert") local class = require(path .. "class") +local tablex = require(path .. "tablex") local async = class({ name = "async", @@ -72,10 +73,13 @@ end --remove a running task based on the reference we got earlier function async:remove(task) task.remove = true - -- can't remove the currently running one from lists - if coroutine.status(task[1]) ~= "running" then - return table.remove_value(self.tasks, task) - or table.remove_value(self.tasks_stalled, task) + if coroutine.status(task[1]) == "running" then + --removed the current running task + return true + else + --remove from the queues + return tablex.remove_value(self.tasks, task) + or tablex.remove_value(self.tasks_stalled, task) end end