driver-core/src/main/com/mongodb/internal/connection/ConcurrentLinkedDeque.java
Node<E> replace(E newElement) {
            for (;;) {
                Node<E> b = getPrev();
                Node<E> f = getNext();
                if (b == null || f == null || f.isMarker())
                    return null;
                Node<E> x = new Node<E>(newElement, f, b);
                if (casNext(f, new Node<E>(x))) {
                    b.successor(); // to relink b
                    x.successor(); // to relink f
                    return x;
                }
            }
        }
Node<E> replace(E newElement) {
            for (;;) {
                Node<E> b = getPrev();
                Node<E> f = getNext();
                if (b == null || f == null || f.isMarker())
                    return null;
                Node<E> x = new Node<E>(newElement, f, b);
                if (casNext(f, new Node<E>(x))) {
                    b.successor(); // to relink b
                    x.successor(); // to relink f
                    return x;
                }
            }
        }
Node < E > replace ( E newElement ) { for ( ; ; ) { Node < E > b = getPrev ( ) ; Node < E > f = getNext ( ) ; if ( b == null || f == null || f . isMarker ( ) ) return null ; Node < E > x = new Node < E > ( newElement , f , b ) ; if ( casNext ( f , new Node < E > ( x ) ) ) { b . successor ( ) ; // to relink b x . successor ( ) ; // to relink f return x ; } } }
Tries to insert a node holding element to replace this node.
failing if already deleted.  A currently unused proof of
concept that demonstrates atomic node content replacement.

Although this implementation ensures that exactly one
version of this Node is alive at a given time, it fails to
maintain atomicity in the sense that iterators may
encounter both the old and new versions of the element.

@param newElement the new element
@return the new node, or null on failure
Tries to insert a node holding element to replace this node . failing if already deleted . A currently unused proof of concept that demonstrates atomic node content replacement .