public function idle()
{
if ($this->wait) {
$taskToDoStorage = $this->pure->getStorage('tasks_to_do');
foreach ($this->tasksToDo as $serverName => $taskName) {
if (!$taskToDoStorage->has($serverName)) {
$this->informer->endOnServer($serverName);
unset($this->tasksToDo[$serverName]);
}
}
if (count($taskToDoStorage) === 0) {
if ($this->isSuccessfullyFinished) {
$this->informer->endTask();
} else {
$this->informer->taskError($this->hasNonFatalException);
}
// We waited all workers to finish their tasks.
// Wait no more!
$this->wait = false;
if ($this->isSuccessfullyFinished || $this->hasNonFatalException) {
// Reset to default for next tasks.
$this->isSuccessfullyFinished = true;
}
}
}
}