Example #1
0
 public function timeout($timeout = null)
 {
     if ($timeout !== null) {
         $this->lastTimeout = $timeout;
     }
     event_timer_add($this->ev, $this->lastTimeout);
 }
Example #2
0
 /**
  * Adds an event timer to the set of monitored events.
  *
  * @see event_add
  * @link http://www.php.net/manual/en/function.event-add.php
  *
  * @param null $events Not used here
  *
  * @throws EventException
  *
  * @return bool
  */
 public function enable($events = null)
 {
     if ($this->enabled || !$this->prepared) {
         return false;
     }
     if (!$this->check()) {
         throw $this->exception('Event already freed and could not be used.');
     }
     if (false === event_timer_add($this->resource, $this->timeout)) {
         throw $this->exception('Could not add timer event (event_timer_add).');
     }
     $this->base->enableEvent($this->name);
     $this->enabled = true;
     return true;
 }
 private function _onTimer($connection, $flag, $timer)
 {
     event_timer_add($timer, $this->timer * 1000000);
     $this->onTimer();
 }