wait() публичный Метод

public wait ( $hang = true )
 /**
  * @param InputInterface $input
  * @param OutputInterface $out
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $out)
 {
     $this->outputHeading($out, "Transfer Patterns");
     $scanDate = $this->getNextScanDate();
     $nonTimetableConnections = $this->outputTask($out, "Loading non-timetable connections", function () use($scanDate) {
         return $this->scheduleProvider->getNonTimetableConnections(strtotime($scanDate . " UTC"));
     });
     $timetables = $this->outputTask($out, "Loading timetables", function () use($scanDate) {
         return $this->scheduleProvider->getTimetableConnections(strtotime("{$scanDate} 00:00 UTC"));
     });
     $interchange = $this->outputTask($out, "Loading interchange", function () {
         return $this->scheduleProvider->getInterchangeTimes();
     });
     $stations = array_keys($this->stationProvider->getLocations());
     $persistence = new TransferPatternPersistence($timetables, $nonTimetableConnections, $interchange);
     $this->outputTask($out, "Calculating transfer patterns", function () use($stations, $persistence, $scanDate) {
         //            $persistence->calculateTransferPatternsForStation(call_user_func($this->dbFactory), "MYB", $scanDate);
         //            return;
         $callable = function ($station) use($persistence, $scanDate) {
             $persistence->calculateTransferPatternsForStation(call_user_func($this->dbFactory), $station, $scanDate);
         };
         $this->processManager->process($stations, $callable, $this->forkStrategy);
         $this->processManager->wait();
     });
     $this->setLastScanDate($scanDate);
     $this->outputMemoryUsage($out);
     return 0;
 }
Пример #2
0
 /**
  * Test large batch sizes
  *
  * @dataProvider batchProvider
  */
 public function testLargeBatchProcessing($rangeEnd)
 {
     $expected = array_fill(0, $rangeEnd, null);
     /** @var Fork $fork */
     $fork = $this->manager->process($expected, function ($item) {
         return $item;
     });
     $this->manager->wait();
     $this->assertEquals($expected, $fork->getResult());
 }
Пример #3
0
 /**
  * Tests that locks will be released automatically.
  *
  * @param callable $mutexFactory The Mutex factory.
  * @test
  * @dataProvider provideMutexFactories
  */
 public function testLiveness(callable $mutexFactory)
 {
     $manager = new ProcessManager();
     $manager->fork(function () use($mutexFactory) {
         $mutex = call_user_func($mutexFactory);
         $mutex->synchronized(function () {
             exit;
         });
     });
     $manager->wait();
     sleep(self::TIMEOUT - 1);
     $mutex = call_user_func($mutexFactory);
     $mutex->synchronized(function () {
     });
 }