function AbstractDriver::delay
Overrides Driver::delay
File
-
vendor/
revolt/ event-loop/ src/ EventLoop/ Internal/ AbstractDriver.php, line 147
Class
- AbstractDriver
- Event loop driver which implements all basic operations to allow interoperability.
Namespace
Revolt\EventLoop\InternalCode
public function delay(float $delay, \Closure $closure) : string {
if ($delay < 0) {
throw new \Error("Delay must be greater than or equal to zero");
}
$timerCallback = new TimerCallback($this->nextId++, $delay, $closure, $this->now() + $delay);
$this->callbacks[$timerCallback->id] = $timerCallback;
$this->enableQueue[$timerCallback->id] = $timerCallback;
return $timerCallback->id;
}