add a interval timer
@param float    $ms
@param callable $callback
@param mixed    $params
@return mixed
351645
public static function tick(float $ms, callable $callback, $params = null)
    {
        $tid = Timer::tick($ms, $callback, $params);

        // save meta info
        self::$timers[$tid] = [
            'type'     => 'tick',
            'ctime'    => \time(), // add time.
            'interval' => $ms,
        ];

        return $tid;
    }
267864
public function trigger($event, $params = array()) {
        $eventObject = is_object($event) ? $event : new GenericEvent($event, $params);
        foreach ($this->getListeners($eventObject) as $callback) {
            if (is_array($callback) && count($callback) == 2) {
                list($key, $function) = $callback;
                if (is_string($key) && !class_exists($key) && $this->getServiceManager()->has($key)) {
                    $service = $this->getServiceManager()->get($key);
                    $callback = [$service, $function];
                }
            }
            call_user_func($callback, $eventObject);
        }
    }
1262248
protected function dispatchConsumerTimingEvent($intervalMs, MessageInterface $message)
    {
        $event = new TimingEvent(TimingEvent::CONSUMER_TIMING);
        $event->setIntervalMs($intervalMs);
        $event->setMessage($message);

        if (null !== ($dispatcher = $this->getEventDispatcher())) {
            $dispatcher->dispatch(TimingEvent::CONSUMER_TIMING, $event);
        }
    }
747829
public function addInterval($millisecond, $callback, $args=null)
    {
        return $this->add($millisecond, static::EV_INTERVAL, $callback, $args);
    }
250231
public function setUserCallback (callable $callback)
	{
		//$this->usercallback = $callback;

		if (count ($this->usercallback) > 0)
			throw new InvalidParameter ("A usercallback was already set. Use addUserCallback to add multiple callbacks");

		$this->addUserCallback ('default', $callback);

		return $this;
	}
8638
public function setCallback(callable $callback, array $params = [])
    {
        if ($this->hasCallback()) {
            throw new ArchException('Callback already defined');
        }
        $this->callback = $callback;
        $this->callbackParams = $params;
        return $this;
    }
810879
public function addMSecs($ms)
    {
        if (is_int($ms) === false) {
            throw new MWrongTypeException("\$ms", "int", gettype($ms));
        }

        $mseconds = $this->mseconds;
        $mseconds += $ms;

        $return = new MTime(0, 0, 0, $mseconds);

        return $return;
    }
1139839
public function setCallback($object, $callbackFunction, $parameters = array())
    {
        $this->callbackObject = $object;

        $this->callbackFunction = $callbackFunction;

        $this->callbackParameters = $parameters;

        return $this;
    }
951421
public function resize($params) {
		//update the event
		$this->end_timestamp = $params['new_end_timestamp'];
		$this->end_date = $params['new_end_date'];
		$this->end_time = $params['new_end_time'];
		$this->end_delta = $params['new_end_timestamp'] - $this->getStartTimestamp(); // how long this is in seconds

		$this->repeat_end_timestamp = $this->calculateRepeatEndTimestamp();
		return true;
	}
1244531
public static function add($time_interval, $func, $args = array(), $persistent = true)
    {
        if ($time_interval <= 0) {
            echo new Exception("bad time_interval");
            return false;
        }

        if (self::$_event) {
            return self::$_event->add($time_interval,
                $persistent ? EventInterface::EV_TIMER : EventInterface::EV_TIMER_ONCE, $func, $args);
        }

        if (!is_callable($func)) {
            echo new Exception("not callable");
            return false;
        }

        if (empty(self::$_tasks)) {
            pcntl_alarm(1);
        }

        $time_now = time();
        $run_time = $time_now + $time_interval;
        if (!isset(self::$_tasks[$run_time])) {
            self::$_tasks[$run_time] = array();
        }
        self::$_tasks[$run_time][] = array($func, (array)$args, $persistent, $time_interval);
        return 1;
    }
442874
private static function _checkCallback($cls, $callback, $context)
    {
        self::_initiateCallbacks($cls);
        foreach (self::$_callbacks[$cls][$callback] as $func) {
            if (!call_user_func(array($context, $func))) {
                return false;
            }
        }
        return true;
    }
370863
public static function addSecond($ts = null, $num = 1)
	{
		return sfTime::add($ts, $num, sfTime::SECOND);
	}
486225
public function setTimeout ($ms) {
    if (defined('CURLOPT_TIMEOUT_MS')) {
      $this->addCurlOption(CURLOPT_TIMEOUT_MS, $ms);

    } else {
      // older versions of php/libcurl don't have the sub-second timeout
      // functionality. Convert to nearest whole seconds not less than 1.
      $this->addCurlOption(CURLOPT_TIMEOUT, max(1, round($ms / 1000)));
    }
    return $this;
  }
189922
public function start($interval = 1000000, $timeout = null, Closure $callback = null)
    {
        $this->startWatch($interval, $timeout, $callback);
    }
833951
def msg(self, *args, **kwargs):
        ""
        if self.timestamp is None or self._interval_reached():
            self.callback(*args, **kwargs)
            self.reset()
34365
public function timeout($ms)
    {
        $this->timeout = (integer) $ms;
        $this->mongoCursor->timeout($ms);
        return $this;
    }
576203
public function addCall($method, $params = array())
	{
		$call = array('name' => $method, 'params' => $params);

		$calls = $this->listCalls();
		$calls[] = $call;
		$this->setOption('calls', $calls);

		return $call;
	}