/**
  * Checks for the stop condition of this strategy
  *
  * @param WorkerEvent $event
  * @return string
  */
 public function onStopConditionCheck(WorkerEvent $event)
 {
     if ($this->interrupted) {
         $event->exitWorkerLoop();
         $this->state = sprintf("interrupt by an external signal on '%s'", $event->getName());
     }
 }
Example #2
0
 /**
  * @param WorkerEvent $event
  */
 public function onSomeListener($event)
 {
     $this->runCount++;
     if ($this->maxRuns && $this->runCount >= $this->maxRuns) {
         $event->exitWorkerLoop();
         $this->state = sprintf('maximum of %s jobs processed', $this->runCount);
     } else {
         $this->state = sprintf('%s jobs processed', $this->runCount);
     }
 }
 public function onStopConditionCheck(WorkerEvent $event)
 {
     $this->runCount++;
     if ($this->maxRuns && $this->runCount >= $this->maxRuns) {
         $event->exitWorkerLoop();
         $this->state = sprintf('maximum of %s jobs processed', $this->runCount);
     } else {
         $this->state = sprintf('%s jobs processed', $this->runCount);
     }
 }
 /**
  * @param  WorkerEvent $event
  * @return void
  */
 public function onStopConditionCheck(WorkerEvent $event)
 {
     // @see http://php.net/manual/en/features.gc.collecting-cycles.php
     if (gc_enabled()) {
         gc_collect_cycles();
     }
     $usage = memory_get_usage();
     if ($this->maxMemory && $usage > $this->maxMemory) {
         $event->exitWorkerLoop();
         $this->state = sprintf("memory threshold of %s exceeded (usage: %s)", $this->humanFormat($this->maxMemory), $this->humanFormat($usage));
     } else {
         $this->state = sprintf('%s memory usage', $this->humanFormat($usage));
     }
 }
 /**
  * @param  WorkerEvent $event
  * @return void
  */
 public function onStopConditionCheck(WorkerEvent $event)
 {
     if ($event->getName() == WorkerEvent::EVENT_PROCESS_IDLE) {
         if ($this->previousIdlingTime + $this->idleThrottleTime > microtime(true)) {
             return;
         } else {
             $this->previousIdlingTime = microtime(true);
         }
     }
     if (!count($this->files)) {
         $this->constructFileList();
         $this->state = sprintf("watching %s files for modifications", count($this->files));
     }
     foreach ($this->files as $checksum => $file) {
         if (!file_exists($file) || !is_readable($file) || (string) $checksum !== hash_file('crc32', $file)) {
             $event->exitWorkerLoop();
             $this->state = sprintf("file modification detected for '%s'", $file);
         }
     }
 }
 /**
  * Callback facilitating the worker loop
  *
  * @param WorkerEvent $e
  */
 public function callbackProcessQueueSetOptionsOnWorkerEvent(WorkerEvent $e)
 {
     $e->exitWorkerLoop();
     $this->eventOptions = $e->getOptions();
 }