/** * @param JobInterface $job * @param $maxProcesses * @return \queue\process\Fork */ public function runAsync(JobInterface $job, $maxProcesses) { $fork = $this->processManager->fork(function () use($job, $maxProcesses) { $this->run($job, $maxProcesses); }); return $fork; }
protected function runWorkerProcess($routeName) { $worker = $this->workerFactory->getOneRouteWorker($this->brokerName, $routeName, $this->processesPerWorker); $worker->setMode($this->mode); $worker->setStopIfNoJob(true); $fork = $this->processManager->fork(function () use($worker) { $worker->work(); })->afterExit(function () use($routeName) { unset($this->processes[$routeName]); }); $this->processes[$routeName] = $fork; }
/** * @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; }