addPeriodicTimer() 공개 메소드

The execution order of timers scheduled to execute at the same time is not guaranteed.
public addPeriodicTimer ( float $interval, callable $callback ) : Kraken\Loop\Timer\TimerInterface
$interval float
$callback callable
리턴 Kraken\Loop\Timer\TimerInterface
예제 #1
0
 /**
  * Start time register.
  *
  * Time register purpose is to cyclically increase timestamp representing last active tick of event loop. This method
  * allows model to not mark external sockets wrongly as offline because of its own heavy load.
  */
 private function startTimeRegister()
 {
     if ($this->rTimer === null && $this->flags['enableHeartbeat'] === true && $this->flags['enableTimeRegister'] === true) {
         $proxy = $this;
         $this->rTimer = $this->loop->addPeriodicTimer($this->options['timeRegisterInterval'] / 1000, function () use($proxy) {
             $now = round(microtime(true) * 1000);
             $proxy->connectionPool->setNow(function () use($now) {
                 return $now;
             });
         });
     }
 }
예제 #2
0
 /**
  * @override
  * @inheritDoc
  */
 public function addPeriodicTimer($interval, callable $callback)
 {
     return new ReactTimer($this->loop->addPeriodicTimer($interval, $callback));
 }