mirror of
https://github.com/1bardesign/batteries.git
synced 2024-09-20 00:42:15 +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 path = (...):gsub("async", "")
|
||||||
local assert = require(path .. "assert")
|
local assert = require(path .. "assert")
|
||||||
local class = require(path .. "class")
|
local class = require(path .. "class")
|
||||||
|
local tablex = require(path .. "tablex")
|
||||||
|
|
||||||
local async = class({
|
local async = class({
|
||||||
name = "async",
|
name = "async",
|
||||||
@ -72,10 +73,13 @@ end
|
|||||||
--remove a running task based on the reference we got earlier
|
--remove a running task based on the reference we got earlier
|
||||||
function async:remove(task)
|
function async:remove(task)
|
||||||
task.remove = true
|
task.remove = true
|
||||||
-- can't remove the currently running one from lists
|
if coroutine.status(task[1]) == "running" then
|
||||||
if coroutine.status(task[1]) ~= "running" then
|
--removed the current running task
|
||||||
return table.remove_value(self.tasks, task)
|
return true
|
||||||
or table.remove_value(self.tasks_stalled, task)
|
else
|
||||||
|
--remove from the queues
|
||||||
|
return tablex.remove_value(self.tasks, task)
|
||||||
|
or tablex.remove_value(self.tasks_stalled, task)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user