Swoole Timer

Timer can be used to schedule a task to be executed at certain time interval.

It is similar to Swoole\Server->after which are used to schedule a task to be executed one-time.

Timer is implemented based on Linux timerfd and epoll.

Methods

  • Swoole\Timer->set
  • Swoole\Timer->tick
  • Swoole\Timer->after
  • Swoole\Timer->list
  • Swoole\Timer->stats
  • Swoole\Timer->info
  • Swoole\Timer->exists
  • Swoole\Timer->clear
  • Swoole\Timer->clearAll

    Example

    <?php
    function run($timerid, $param) {
        var_dump($timerid);
        var_dump($param);
    }
    Swoole\Timer->tick(1000, "run", ["param1", "param2"]);