Kraken\Loop\Timer\TimerBox::add PHP Method

add() public method

public add ( Kraken\Loop\Timer\TimerInterface $timer )
$timer Kraken\Loop\Timer\TimerInterface
    public function add(TimerInterface $timer)
    {
        $interval = $timer->getInterval();
        $scheduledAt = $interval + $this->getTime();
        $this->timers->attach($timer, $scheduledAt);
        $this->scheduler->insert($timer, -$scheduledAt);
    }

Usage Example

Beispiel #1
0
 /**
  * @override
  * @inheritDoc
  */
 public function addPeriodicTimer($interval, callable $callback)
 {
     $timer = new Timer($this, $interval, $callback, true);
     $this->timers->add($timer);
     return $timer;
 }