コード例 #1
0
ファイル: ProcessesManager.php プロジェクト: rbaarsma/fastest
 public function assertNProcessRunning(QueueInterface &$queue, Processes &$processes = null)
 {
     $parallelProcesses = max(1, min($queue->count(), $this->maxNumberOfParallelProcesses));
     if (null === $processes) {
         $channelsEmpty = range(1, $parallelProcesses);
         $processes = new Processes(array());
         if (false !== $this->beforeCommand && null !== $this->beforeCommand) {
             return $this->createProcessesForTheBeforeCommand($channelsEmpty, $processes);
         }
     } else {
         $channelsEmpty = $processes->getIndexesOfCompletedChannel();
     }
     if (count($channelsEmpty) == 0) {
         usleep(100);
         return true;
     }
     foreach ($channelsEmpty as $currentChannel) {
         if ($queue->isEmpty()) {
             return false;
         }
         $currentProcessNumber = $this->getCurrentProcessCounter();
         $this->incrementForThisChannel($currentChannel);
         $process = $this->processFactory->createAProcess($queue->pop(), $currentChannel, $currentProcessNumber, $this->isFirstForThisChannel($currentChannel));
         $processes->add($currentChannel, $process);
         $processes->start($currentChannel);
     }
     return true;
 }
コード例 #2
0
 public function renderBody(QueueInterface $queue, Processes $processes)
 {
     $now = $queue->count();
     $errorCount = $processes->countErrors();
     if ($errorCount > 0) {
         $this->bar->setBarCharacter('<error>=</error>');
         $this->writeMessage(sprintf("<error>%d</error> failures.", $errorCount), 'number');
     }
     if ($this->last != $now) {
         $this->bar->advance($this->last - $now);
     }
     $this->last = $now;
     return $errorCount;
 }
コード例 #3
0
ファイル: ParallelCommand.php プロジェクト: rbaarsma/fastest
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @param QueueInterface $queue
  * @param ProcessesManager $processManager
  * @return array
  */
 private function doExecute(InputInterface $input, OutputInterface $output, QueueInterface $queue, ProcessesManager $processManager)
 {
     $processes = null;
     if ($this->isVerbose($output)) {
         $progressBar = new VerboseRenderer($queue->count(), $this->hasErrorSummary($input), $output, $processManager->getNumberOfProcessExecutedByTheBeforeCommand());
     } else {
         $progressBar = new ProgressBarRenderer($queue->count(), $this->hasErrorSummary($input), $output, $this->getHelper('progress'), $processManager->getNumberOfProcessExecutedByTheBeforeCommand());
     }
     $progressBar->renderHeader($queue);
     while ($processManager->assertNProcessRunning($queue, $processes)) {
         $progressBar->renderBody($queue, $processes);
     }
     /**
      * @var Processes $processes
      */
     $processes->cleanUP();
     //it is not getting called with -p1 after the last process otherwise
     $processes->wait(function () use($progressBar, $queue, $processes) {
         $progressBar->renderBody($queue, $processes);
     });
     $progressBar->renderFooter($queue, $processes);
     return $processes;
 }