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;
}