示例#1
0
文件: Worker.php 项目: zwilias/qman
 /**
  * @param $workers
  */
 protected function registerWatchers($workers)
 {
     array_map(function (\Beanie\Worker $worker) {
         $worker->getTubeStatus()->setWatchedTubes($this->config->getWatchedTubes());
         $this->eventLoop->registerJobListener($worker);
     }, $workers);
     $this->eventLoop->registerBreakCondition('time to live', [$this, 'checkTimeToLive'])->registerBreakCondition('maximal memory usage', [$this, 'checkMaximalMemoryUsage']);
     array_map(function ($terminationSignal) {
         $this->eventLoop->registerBreakSignal($terminationSignal);
     }, $this->config->getTerminationSignals());
 }
示例#2
0
 /**
  * @param EventLoop $eventLoop
  * @return $this
  */
 public function withEventLoop(EventLoop $eventLoop)
 {
     $eventLoop->setLogger($this->logger);
     $this->eventLoop = $eventLoop;
     return $this;
 }
示例#3
0
 public function testDestructor_stopsAllWatchers()
 {
     $watchers = [];
     $watchers[] = $this->getWatcherMock(['stop']);
     $watchers[] = $this->getWatcherMock(['stop']);
     $watchers[] = $this->getWatcherMock(['stop']);
     $eventLoop = new EventLoop();
     array_map(function ($watcher) use($eventLoop) {
         /** @var \PHPUnit_Framework_MockObject_MockObject|WatcherMock $watcher */
         $watcher->expects($this->atLeastOnce())->method('stop')->willReturn(true);
         $eventLoop->registerWatcher($watcher);
     }, $watchers);
     $eventLoop->__destruct();
 }