Fix CooperativeScheduler, issue #18;

CooperativeScheduler wasn't removing 'dead' coroutines that errored out.
This commit is contained in:
Greatwolf 2017-05-06 17:06:48 -07:00
parent 1ca187506b
commit 71f6f7669a

View File

@ -62,14 +62,14 @@ function CooperativeScheduler:update(delta)
if self.currentTime >= task.due then
local success, delay = coroutine.resume(task.thread)
if success then
task.due = math.max(task.due + (delay or 0), self.currentTime)
else
error(delay)
end
if coroutine.status(task.thread) == 'dead' then
table.remove(self.tasks, i)
else
task.due = math.max(task.due + (delay or 0), self.currentTime)
end
if not success then
error(delay)
end
end
end