src/WorkerPool.php
public function create(WorkerInterface $worker) {
		$this->initialPoolSize = $this->workerPoolSize;
		$this->parentPid = getmypid();
		$this->worker = $worker;
		if ($this->created) {
			throw new WorkerPoolException('The pool has already been created.');
		}

		$this->created = TRUE;
		// when adding signals use pcntl_signal_dispatch(); or declare ticks
		foreach ($this->signals as $signo) {
			pcntl_signal($signo, array($this, 'signalHandler'));
		}

		// no Semaphore attached? -> create one
		if (!($this->semaphore instanceof Semaphore)) {
			$this->semaphore = new Semaphore();
			$this->semaphore->create(Semaphore::SEM_RAND_KEY);
		}
		elseif(!$this->semaphore->isCreated()) {
			$this->semaphore->create(Semaphore::SEM_RAND_KEY);
		}

		ProcessDetails::setProcessTitle(
			$this->parentProcessTitleFormat,
			array(
				'basename' => basename($_SERVER['PHP_SELF']),
				'fullname' => $_SERVER['PHP_SELF'],
				'class' => get_class($this)
			)
		);

		for ($this->currentWorkerIndex = 1; $this->currentWorkerIndex <= $this->workerPoolSize; $this->currentWorkerIndex++) {
			$this->createWorker($this->currentWorkerIndex);
		}

		return $this;
	}
public function create(WorkerInterface $worker) {
		$this->initialPoolSize = $this->workerPoolSize;
		$this->parentPid = getmypid();
		$this->worker = $worker;
		if ($this->created) {
			throw new WorkerPoolException('The pool has already been created.');
		}

		$this->created = TRUE;
		// when adding signals use pcntl_signal_dispatch(); or declare ticks
		foreach ($this->signals as $signo) {
			pcntl_signal($signo, array($this, 'signalHandler'));
		}

		// no Semaphore attached? -> create one
		if (!($this->semaphore instanceof Semaphore)) {
			$this->semaphore = new Semaphore();
			$this->semaphore->create(Semaphore::SEM_RAND_KEY);
		}
		elseif(!$this->semaphore->isCreated()) {
			$this->semaphore->create(Semaphore::SEM_RAND_KEY);
		}

		ProcessDetails::setProcessTitle(
			$this->parentProcessTitleFormat,
			array(
				'basename' => basename($_SERVER['PHP_SELF']),
				'fullname' => $_SERVER['PHP_SELF'],
				'class' => get_class($this)
			)
		);

		for ($this->currentWorkerIndex = 1; $this->currentWorkerIndex <= $this->workerPoolSize; $this->currentWorkerIndex++) {
			$this->createWorker($this->currentWorkerIndex);
		}

		return $this;
	}
public function create ( WorkerInterface $ worker ) { $ this -> initialPoolSize = $ this -> workerPoolSize ; $ this -> parentPid = getmypid ( ) ; $ this -> worker = $ worker ; if ( $ this -> created ) { throw new WorkerPoolException ( 'The pool has already been created.' ) ; } $ this -> created = TRUE ; // when adding signals use pcntl_signal_dispatch(); or declare ticks foreach ( $ this -> signals as $ signo ) { pcntl_signal ( $ signo , array ( $ this , 'signalHandler' ) ) ; } // no Semaphore attached? -> create one if ( ! ( $ this -> semaphore instanceof Semaphore ) ) { $ this -> semaphore = new Semaphore ( ) ; $ this -> semaphore -> create ( Semaphore :: SEM_RAND_KEY ) ; } elseif ( ! $ this -> semaphore -> isCreated ( ) ) { $ this -> semaphore -> create ( Semaphore :: SEM_RAND_KEY ) ; } ProcessDetails :: setProcessTitle ( $ this -> parentProcessTitleFormat , array ( 'basename' => basename ( $ _SERVER [ 'PHP_SELF' ] ) , 'fullname' => $ _SERVER [ 'PHP_SELF' ] , 'class' => get_class ( $ this ) ) ) ; for ( $ this -> currentWorkerIndex = 1 ; $ this -> currentWorkerIndex <= $ this -> workerPoolSize ; $ this -> currentWorkerIndex ++ ) { $ this -> createWorker ( $ this -> currentWorkerIndex ) ; } return $ this ; }
Creates the worker pool (forks the children)

Please close all open resources before running this function.
Child processes are going to close all open resources uppon exit,
leaving the parent process behind with invalid resource handles.
@param \QXS\WorkerPool\WorkerInterface $worker the worker, that runs future tasks
@throws \RuntimeException
@throws WorkerPoolException
@return WorkerPool
Creates the worker pool ( forks the children )