/** * @expectedException \Tonic\ParallelProcessRunner\Exception\ProcessesMustBeInReadyStatusException */ public function testAddNotReadyProcess() { $process = $this->getProcess(-1); try { $collection = new WaitProcessCollection(); $collection->add($process); } catch (ProcessesMustBeInReadyStatusException $exception) { $this->assertEquals($process, $exception->getProcess()); throw $exception; } }
/** * @return $this * * @throws NotProcessException */ protected function startWaitingProcesses() { $required = max(0, $this->maxParallelProcess - $this->activeCollection->count()); foreach ($this->waitCollection->spliceByStatus(Process::STATUS_READY, $required) as $process) { $this->activeCollection->add($process); $this->getEventDispatcher()->dispatch(ParallelProcessRunnerEventType::PROCESS_START_BEFORE, new ProcessEvent($process)); $process->start(function ($outType, $outData) use($process) { $this->getEventDispatcher()->dispatch(ParallelProcessRunnerEventType::PROCESS_OUT, new ProcessOutEvent($process, $outType, $outData)); }); } return $this; }