private function waitForAllToFinish()
{
$toStop = $this->workers;
while (count($toStop) > 0) {
$toCheck = $this->streamsOf($toStop);
$new = $this->waitForStreamsToChange($toCheck);
foreach ($this->progressedWorkers() as $index => $worker) {
if (!$worker->isRunning()) {
$this->flushWorker($worker);
unset($toStop[$index]);
}
}
}
}