PHPDaemon\Core\Timer::__construct PHP Method

__construct() public method

Constructor
public __construct ( callable $cb, integer $timeout = null, integer | string $id = null, integer $priority = null )
$cb callable Callback
$timeout integer Timeout
$id integer | string Timer ID
$priority integer Priority
    public function __construct($cb, $timeout = null, $id = null, $priority = null)
    {
        if ($id === null) {
            $id = ++self::$counter;
        } else {
            $id = (string) $id;
        }
        $this->id = $id;
        $this->cb = $cb;
        if ($this->eventLoop === null) {
            $this->eventLoop = EventLoop::$instance;
        }
        $this->ev = $this->eventLoop->timer([$this, 'eventCall']);
        if ($priority !== null) {
            $this->setPriority($priority);
        }
        if ($timeout !== null) {
            $this->timeout($timeout);
        }
        self::$list[$id] = $this;
    }