public function run() { do { if ($this->processManager->getRunningProcessesCount() > 0) { $this->processManager->waitNext(false); } while ($this->processManager->getRunningProcessesCount() < $this->maxWorkers && ($route = $this->getNextRoute())) { $this->runWorkerProcess($route); } } while ($this->isContinue()); }
/** * @return bool */ protected function isContinue() { pcntl_signal_dispatch(); if ($this->isTerminated) { return false; } if ($this->processManager->getRunningProcessesCount() == 0) { if ($this->stopIfNoJob) { return false; } //\Utility::logText('waiting'); sleep(1); } return true; }