Ver código fonte

Merge pull request #19 from greatwolf/master

Fix CooperativeScheduler, issue #18;
Bjorn Swenson 8 anos atrás
pai
commit
e5decf0ac8
1 arquivos alterados com 5 adições e 5 exclusões
  1. 5 5
      src/schedulers/cooperativescheduler.lua

+ 5 - 5
src/schedulers/cooperativescheduler.lua

@@ -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)
+      if coroutine.status(task.thread) == 'dead' then
+        table.remove(self.tasks, i)
       else
-        error(delay)
+        task.due = math.max(task.due + (delay or 0), self.currentTime)
       end
 
-      if coroutine.status(task.thread) == 'dead' then
-        table.remove(self.tasks, i)
+      if not success then
+        error(delay)
       end
     end
   end