fixed reliance on tablex exported to table in async:remove

This commit is contained in:
Max Cahill 2023-08-08 12:57:35 +10:00
parent 758533445c
commit 6e3a285f97

View File

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