function TimerQueue::extract
Deletes and returns the callback on top of the heap if it has expired, otherwise null is returned.
Time complexity: O(log(n)).
Parameters
float $now Current event loop time.:
Return value
TimerCallback|null Expired callback at the top of the heap or null if the callback has not expired.
File
-
vendor/
revolt/ event-loop/ src/ EventLoop/ Internal/ TimerQueue.php, line 61
Class
- TimerQueue
- Uses a binary tree stored in an array to implement a heap.
Namespace
Revolt\EventLoop\InternalCode
public function extract(float $now) : ?TimerCallback {
if (!$this->callbacks) {
return null;
}
$callback = $this->callbacks[0];
if ($callback->expiration > $now) {
return null;
}
$this->removeAndRebuild(0);
return $callback;
}