public function attach(Process $process)
    {
        if ($this->stopped) {
            throw new RuntimeException('Could not attach child to non-running pool');
        }

        $firstProcess = $this->getFirstProcess();
        if ($this->isRunning()
            && $firstProcess instanceof Process
            && $this->count() >= $this->processLimit) {
            $firstProcess->wait();
            $this->detach($firstProcess);
        }
        $this->process->attach($process);

        if ($this->isRunning()) {
            $process->start();
        }
    }
public function attach(Process $process)
    {
        if ($this->stopped) {
            throw new RuntimeException('Could not attach child to non-running pool');
        }

        $firstProcess = $this->getFirstProcess();
        if ($this->isRunning()
            && $firstProcess instanceof Process
            && $this->count() >= $this->processLimit) {
            $firstProcess->wait();
            $this->detach($firstProcess);
        }
        $this->process->attach($process);

        if ($this->isRunning()) {
            $process->start();
        }
    }
public function attach ( Process $ process ) { if ( $ this -> stopped ) { throw new RuntimeException ( 'Could not attach child to non-running pool' ) ; } $ firstProcess = $ this -> getFirstProcess ( ) ; if ( $ this -> isRunning ( ) && $ firstProcess instanceof Process && $ this -> count ( ) >= $ this -> processLimit ) { $ firstProcess -> wait ( ) ; $ this -> detach ( $ firstProcess ) ; } $ this -> process -> attach ( $ process ) ; if ( $ this -> isRunning ( ) ) { $ process -> start ( ) ; } }
Attachs a new process to the pool.

Try to detach finished processes from the pool when reaches its limit.

@param Process $process
Attachs a new process to the pool .