diff --git a/src/FuzeWorks/Async/Supervisors/ParallelSuperVisor.php b/src/FuzeWorks/Async/Supervisors/ParallelSuperVisor.php index 18c7fa2..c91e33d 100644 --- a/src/FuzeWorks/Async/Supervisors/ParallelSuperVisor.php +++ b/src/FuzeWorks/Async/Supervisors/ParallelSuperVisor.php @@ -244,24 +244,23 @@ class ParallelSuperVisor implements SuperVisor $this->taskStorage->modifyTask($task); fwrite(STDOUT, "Changed status of task '".$task->getId()."' to status " . Task::getStatusType($task->getStatus()) . PHP_EOL); } - } // Check if all tasks are completed - $allCompleted = true; $anyDelayed = false; + $anyOther = false; foreach ($this->tasks as $task) { - if ($task->getStatus() !== Task::COMPLETED && $task->getStatus() !== Task::CANCELLED) - $allCompleted = false; if ($task->getStatus() === Task::DELAYED) $anyDelayed = true; + elseif ($task->getStatus() !== Task::COMPLETED && $task->getStatus() !== Task::CANCELLED) + $anyOther = true; } // If all are finished and none are delayed - if ($allCompleted && !$anyDelayed) + if (!$anyOther && !$anyDelayed) return SuperVisor::FINISHED; - elseif ($allCompleted && $anyDelayed) + elseif (!$anyOther && $anyDelayed) return SuperVisor::CONSTRAINED; else return SuperVisor::RUNNING;