예제 #1
0
 /**
  * @param LoopEvent $event
  */
 public function sleep(LoopEvent $event)
 {
     $interval = $event->getConfig()->getInterval();
     if (null !== $interval) {
         usleep($interval);
     }
 }
예제 #2
0
 /**
  * @param LoopEvent $event
  */
 public function checkExecutions(LoopEvent $event)
 {
     $repeat = $event->getConfig()->getRepeat();
     $this->executions += 1;
     if (null !== $repeat && $repeat <= $this->executions) {
         throw new LoopException('maximum loop executions reached', 0, $event->getException());
     }
 }
예제 #3
0
파일: Loop.php 프로젝트: RubiconPHP/Loop
 /**
  * @throws \Exception
  */
 public function start()
 {
     try {
         $this->running = true;
         $this->run($this->config->getCallback());
     } catch (LoopException $exception) {
         $this->event->setException($exception);
         $this->stop();
     } catch (\Exception $exception) {
         throw $exception;
     }
 }
예제 #4
0
 /**
  * @param LoopEvent $event
  */
 public function checkStatus(LoopEvent $event)
 {
     if ($event->getTarget()->isStopped()) {
         throw new LoopException('Loop has been stopped', 0, $event->getException());
     }
 }