mirror of
https://github.com/1bardesign/batteries.git
synced 2024-11-25 23:24:35 +00:00
fixed reliance on tablex exported to table in async:remove
This commit is contained in:
parent
758533445c
commit
6e3a285f97
12
async.lua
12
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user