Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TimerQueue.php

function TimerQueue::removeAndRebuild

Parameters

int $node Remove the given node and then rebuild the data array.:

2 calls to TimerQueue::removeAndRebuild()
TimerQueue::extract in vendor/revolt/event-loop/src/EventLoop/Internal/TimerQueue.php
Deletes and returns the callback on top of the heap if it has expired, otherwise null is returned.
TimerQueue::remove in vendor/revolt/event-loop/src/EventLoop/Internal/TimerQueue.php
Removes the given callback from the queue.

File

vendor/revolt/event-loop/src/EventLoop/Internal/TimerQueue.php, line 139

Class

TimerQueue
Uses a binary tree stored in an array to implement a heap.

Namespace

Revolt\EventLoop\Internal

Code

private function removeAndRebuild(int $node) : void {
    $length = \count($this->callbacks) - 1;
    $id = $this->callbacks[$node]->id;
    $left = $this->callbacks[$node] = $this->callbacks[$length];
    $this->pointers[$left->id] = $node;
    unset($this->callbacks[$length], $this->pointers[$id]);
    if ($node < $length) {
        // don't need to do anything if we removed the last element
        $parent = $node - 1 >> 1;
        if ($parent >= 0 && $this->callbacks[$node]->expiration < $this->callbacks[$parent]->expiration) {
            $this->heapifyUp($node);
        }
        else {
            $this->heapifyDown($node);
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal