Пример #1
0
 /**
  * @param $worker callable type is unusable atm
  *
  * @throws DaemonMustBeStartedFirstException
  * @return bool true if worker was spawned, false otherwise
  */
 protected function spawnWorker($worker)
 {
     assert('is_callable($worker)');
     $this->assertDaemonStarted();
     if ($this->maxWorkers === 0) {
         throw new DaemonMustBeStartedFirstException('You must set max workers count to use workers.');
     }
     if (!$this->isWorkerAvailable()) {
         return false;
     }
     $pid = $this->processManager->fork();
     if ($pid) {
         return $pid;
     } else {
         call_user_func($worker);
         exit;
     }
 }