Guarantees that any node which was unlinked before a call to
this method will be unreachable from head after it returns.
Does not guarantee to eliminate slack, only that head will
point to a node that was active while this method was running.
962972
private void updateHead() {
        // Either head already points to an active node, or we keep
        // trying to cas it to the first node until it does.
        Node<E> h, p, q;
        restartFromHead:
        while ((h = head).item == null && (p = h.prev) != null) {
            for (;;) {
                if ((q = p.prev) == null ||
                    (q = (p = q).prev) == null) {
                    // It is possible that p is PREV_TERMINATOR,
                    // but if so, the CAS is guaranteed to fail.
                    if (HEAD.compareAndSet(this, h, p))
                        return;
                    else
                        continue restartFromHead;
                }
                else if (h != head)
                    continue restartFromHead;
                else
                    p = q;
            }
        }
    }
859749
synchronized void unlink(final OtpErlangPid from, final OtpErlangPid to) {
        links.removeLink(from, to);
        try {
            super.sendUnlink(from, to);
        } catch (final IOException e) {
        }
    }
564495
function nodeIsUnscopedBinding(item: Node): boolean {
  const value = getValue(item);
  return value && value.unscoped;
}
586167
def should_remove(self, point, node):
        
        if not self.data == point:
            return False

        return (node is None) or (node is self)
296771
final Node firstDataNode() {
        restartFromHead: for (;;) {
            for (Node p = head; p != null;) {
                Object item = p.item;
                if (p.isData) {
                    if (item != null && item != FORGOTTEN)
                        return p;
                }
                else if (item == null)
                    break;
                if (UNLINKED == (p = p.next))
                    continue restartFromHead;
            }
            return null;
        }
    }
34876
private final void updateHead() {
        // Either head already points to an active node, or we keep
        // trying to cas it to the first node until it does.
        Node<E> h, p, q;
        restartFromHead:
        while ((h = head).item == null && (p = h.prev) != null) {
            for (;;) {
                if ((q = p.prev) == null ||
                    (q = (p = q).prev) == null) {
                    // It is possible that p is PREV_TERMINATOR,
                    // but if so, the CAS is guaranteed to fail.
                    if (casHead(h, p))
                        return;
                    else
                        continue restartFromHead;
                }
                else if (h != head)
                    continue restartFromHead;
                else
                    p = q;
            }
        }
    }
697505
private E firstDataItem() {
        for (Node p = head; p != null; p = succ(p)) {
            Object item = p.item;
            if (p.isData) {
                if (item != null && item != p)
                    return LinkedTransferQueue.<E>cast(item);
            }
            else if (item == null)
                return null;
        }
        return null;
    }
875720
function () {
					oNodeForContext.nodeState.removed = false;
					var iNodeStateFound = that._aRemoved.indexOf(oNodeForContext);
					if (iNodeStateFound != -1) {
						that._aRemoved.splice(iNodeStateFound, 1);
					}
					// clear cache to make sure findNode etc. don't deliver wrong nodes (index is shifted due to adding)
					this._aNodeCache = [];
					that._cleanTreeStateMaps();
					that._fireChange({reason: ChangeReason.Add});
				}
1136976
final void ensureNodeIndex(int nodeIndex) {
        if (!initialized)
            throw new AssertionError("The graph has not yet been initialized.");

        if (nodeIndex < nodeCount)
            return;

        long oldNodes = nodeCount;
        nodeCount = nodeIndex + 1;
        boolean capacityIncreased = nodes.ensureCapacity((long) nodeCount * nodeEntryBytes);
        if (capacityIncreased) {
            long newBytesCapacity = nodes.getCapacity();
            initNodeRefs(oldNodes * nodeEntryBytes, newBytesCapacity);
        }
    }
1073818
private void traverseAndRemoveUnusedReferences(Node root) {
    // Create scope from parent of root node, which also has externs as a child, so we'll
    // have extern definitions in scope.
    Scope scope = scopeCreator.createScope(root.getParent(), null);
    if (!scope.hasSlot(NodeUtil.JSC_PROPERTY_NAME_FN)) {
      // TODO(b/70730762): Passes that add references to this should ensure it is declared.
      // NOTE: null input makes this an extern var.
      scope.declare(
          NodeUtil.JSC_PROPERTY_NAME_FN, /* no declaration node */ null, /* no input */ null);
    }
    worklist.add(new Continuation(root, scope));
    while (!worklist.isEmpty()) {
      Continuation continuation = worklist.remove();
      continuation.apply();
    }

    removeUnreferencedVarsAndPolyfills();
    removeIndependentlyRemovableProperties();
    for (Scope fparamScope : allFunctionParamScopes) {
      removeUnreferencedFunctionArgs(fparamScope);
    }
  }
566181
public boolean remove(Node<E> e) {

        mPutLock.lock();
        mPollLock.lock();
        try {
            if (e == null)
                return false;
    
            if (e.mRemoved)
                return false;
    
            if (mSize.get() == 0)
                return false;

            if (e == mTail) {
                removeTail();
                return true;
            }
            if (e == mHead.mNext) {
                removeHead();
                return true;
            }
            if (mSize.get() < 3)
                return false;

            if (e.mPrev == null || e.mNext == null)
                return false;

            e.mPrev.mNext = e.mNext;
            e.mNext.mPrev = e.mPrev;
            e.mRemoved = true;
            mSize.decrementAndGet();
            mNodePool.returnNode(e);
            return true;
        }
        finally {
            mPollLock.unlock();
            mPutLock.unlock();
        }
    }
657449
private void initHeadTail(Node<E> h, Node<E> t) {
        if (h == t) {
            if (h == null)
                h = t = new Node<E>();
            else {
                // Avoid edge case of a single Node with non-null item.
                Node<E> newNode = new Node<E>();
                NEXT.set(t, newNode);
                PREV.set(newNode, t);
                t = newNode;
            }
        }
        head = h;
        tail = t;
    }
637623
def on_connection_unblocked(self, method_frame):
        
        LOGGER.debug('Connection unblocked: %r', method_frame)
        self.state = self.STATE_READY
        if self.on_ready:
            self.on_ready(self)
864161
void discardUnusedTail()
    {
        // we guard this with the OpOrdering instead of synchronised due to potential dead-lock with CLSM.advanceAllocatingFrom()
        // this actually isn't strictly necessary, as currently all calls to discardUnusedTail occur within a block
        // already protected by this OpOrdering, but to prevent future potential mistakes, we duplicate the protection here
        // so that the contract between discardUnusedTail() and sync() is more explicit.
        try (OpOrder.Group group = appendOrder.start())
        {
            while (true)
            {
                int prev = allocatePosition.get();
                // we set allocatePosition past buffer.capacity() to make sure we always set discardedTailFrom
                int next = buffer.capacity() + 1;
                if (prev == next)
                    return;
                if (allocatePosition.compareAndSet(prev, next))
                {
                    discardedTailFrom = prev;
                    return;
                }
            }
        }
    }
134325
public void disconnect(Node<T> o, Node<T> t) {
    if (!o.equals(t)) {
      o.disconnectFrom(t);
      t.disconnectFrom(o);
    }
  }
29368
def connectionLost(self, reason):
        
        try:
            self.connected = False
            if debug:
                print(self.log_entry("CLOSED =", "none"))

            # Every five minutes: cleanup
            t = time.time()
            if time.time() - self.factory.last_cleanup >= self.cleanup:
                self.factory.last_cleanup = t

                # Delete old passive nodes.
                old_node_ips = []
                for node_ip in list(self.factory.nodes["passive"]):
                    passive_node = self.factory.nodes["passive"][node_ip]
                    # Gives enough time for passive nodes to receive clients.
                    if t - passive_node["time"] >= self.node_lifetime:
                        old_node_ips.append(node_ip)
                for node_ip in old_node_ips:
                    del self.factory.nodes["passive"][node_ip]

                # Delete old simultaneous nodes.
                old_node_ips = []
                for node_ip in list(self.factory.nodes["simultaneous"]):
                    simultaneous_node =\
                        self.factory.nodes["simultaneous"][node_ip]
                    # Gives enough time for passive nodes to receive clients.
                    if t - simultaneous_node["time"] >= self.node_lifetime:
                        old_node_ips.append(node_ip)
                for node_ip in old_node_ips:
                    del self.factory.nodes["simultaneous"][node_ip]

                # Delete old candidates and candidate structs.
                old_node_ips = []
                for node_ip in list(self.factory.candidates):
                    # Record old candidates.
                    old_candidates = []
                    for candidate in self.factory.candidates[node_ip]:
                        # Hole punching is ms time sensitive.
                        # Candidates older than this is safe to assume
                        # they're not needed.
                        if node_ip not in self.factory.nodes["simultaneous"] \
                                and t - candidate["time"] >= self.challenge_timeout * 5:
                            old_candidates.append(candidate)

                    # Remove old candidates.
                    for candidate in old_candidates:
                        self.factory.candidates[node_ip].remove(candidate)

                    # Record old node IPs.
                    if not len(self.factory.candidates[node_ip]) and \
                            node_ip not in self.factory.nodes["simultaneous"]:
                        old_node_ips.append(node_ip)

                # Remove old node IPs.
                for node_ip in old_node_ips:
                    del self.factory.candidates[node_ip]
        except Exception as e:
            error = parse_exception(e)
            log_exception(error_log_path, error)
            print(self.log_entry("ERROR =", error))
1164598
private static synchronized boolean cancelScheduledTimeout(AsyncTimeout node) {
    // Remove the node from the linked list.
    for (AsyncTimeout prev = head; prev != null; prev = prev.next) {
      if (prev.next == node) {
        prev.next = node.next;
        node.next = null;
        return false;
      }
    }

    // The node wasn't found in the linked list: it must have timed out!
    return true;
  }