async fn commit(&mut self) {
        let prev_pointers = match self.insertion_point.take() {
            Some(prev_pointers) => prev_pointers,
            None => return,
        };

        // Keep track of the first node that we might need to erase later.
        let mut maybe_erase = prev_pointers[0].get_mut(0);

        // If there are no insertion nodes, then it means that we're only erasing nodes.
        if self.insertion_nodes.get(0).is_none() {
            // Erase all elements between the insertion point and the current element. The
            // pointers for levels > 0 should already have been done, so it's only level 0 we
            // need to worry about.
            prev_pointers[0].set(0, self.prev_pointers[0].get(0));
        } else {
            // Switch the pointers over so that the insertion chain is spliced in.  This is safe
            // so long as the bottom pointer is done first because that guarantees the new nodes
            // will be found, just maybe not as efficiently.
            for i in 0..self.insertion_nodes.len() {
                if let Some(node) = self.insertion_nodes.get_mut(i) {
                    prev_pointers[i].set(i, Some(node));
                }
            }
        }

        // Switch the epoch so that we can track when existing readers have finished.
        let epoch = {
            let mut read_counts = self.skip_list.read_counts.lock().unwrap();
            let epoch = read_counts.epoch;
            read_counts.epoch = 1 - epoch;
            epoch
        } as usize;

        // Now we need to wait for the old readers to finish.
        poll_fn(|cx| {
            let mut read_counts = self.skip_list.read_counts.lock().unwrap();
            if read_counts.counts[epoch] == 0 {
                Poll::Ready(())
            } else {
                read_counts.waker = Some(cx.waker().clone());
                Poll::Pending
            }
        })
        .await;

        // Now we can free the memory for the erased items.
        let end = self.prev_pointers[0].get_ptr(0);
        loop {
            match maybe_erase {
                Some(node) if node as *const _ != end => {
                    maybe_erase = self.skip_list.free_node(node)
                }
                _ => break,
            }
        }
    }
// Commit splices the new insertion chain into the list.  This *must* be called before the
// iterator is dropped.  This will block waiting for existing readers to finish.
Commit splices the new insertion chain into the list.  This *must* be called before the
iterator is dropped.  This will block waiting for existing readers to finish.
Commit splices the new insertion chain into the list . This * must * be called before the iterator is dropped . This will block waiting for existing readers to finish .
async fn commit(&mut self) {
        let prev_pointers = match self.insertion_point.take() {
            Some(prev_pointers) => prev_pointers,
            None => return,
        };
        // Keep track of the first node that we might need to erase later.
        let mut maybe_erase = prev_pointers[0].get_mut(0);
        // If there are no insertion nodes, then it means that we're only erasing nodes.
        if self.insertion_nodes.get(0).is_none() {
            // Erase all elements between the insertion point and the current element. The
            // pointers for levels > 0 should already have been done, so it's only level 0 we
            // need to worry about.
            prev_pointers[0].set(0, self.prev_pointers[0].get(0));
        } else {
            // Switch the pointers over so that the insertion chain is spliced in.  This is safe
            // so long as the bottom pointer is done first because that guarantees the new nodes
            // will be found, just maybe not as efficiently.
            for i in 0..self.insertion_nodes.len() {
                if let Some(node) = self.insertion_nodes.get_mut(i) {
                    prev_pointers[i].set(i, Some(node));
                }
            }
        }
        // Switch the epoch so that we can track when existing readers have finished.
        let epoch = {
            let mut read_counts = self.skip_list.read_counts.lock().unwrap();
            let epoch = read_counts.epoch;
            read_counts.epoch = 1 - epoch;
            epoch
        } as usize;
        // Now we need to wait for the old readers to finish.
        poll_fn(|cx| {
            let mut read_counts = self.skip_list.read_counts.lock().unwrap();
            if read_counts.counts[epoch] == 0 {
                Poll::Ready(())
            } else {
                read_counts.waker = Some(cx.waker().clone());
                Poll::Pending
            }
        })
        .await;
        // Now we can free the memory for the erased items.
        let end = self.prev_pointers[0].get_ptr(0);
        loop {
            match maybe_erase {
                Some(node) if node as *const _ != end => {
                    maybe_erase = self.skip_list.free_node(node)
                }
                _ => break,
            }
        }
    }
async fn commit ( & mut self ) { let prev_pointers = match self . insertion_point . take ( ) { Some ( prev_pointers ) => prev_pointers , None => return , } ; // Keep track of the first node that we might need to erase later. let mut maybe_erase = prev_pointers [ 0 ] . get_mut ( 0 ) ; // If there are no insertion nodes, then it means that we're only erasing nodes. if self . insertion_nodes . get ( 0 ) . is_none ( ) { // Erase all elements between the insertion point and the current element. The // pointers for levels > 0 should already have been done, so it's only level 0 we // need to worry about. prev_pointers [ 0 ] . set ( 0 , self . prev_pointers [ 0 ] . get ( 0 ) ) ; } else { // Switch the pointers over so that the insertion chain is spliced in.  This is safe // so long as the bottom pointer is done first because that guarantees the new nodes // will be found, just maybe not as efficiently. for i in 0 .. self . insertion_nodes . len ( ) { if let Some ( node ) = self . insertion_nodes . get_mut ( i ) { prev_pointers [ i ] . set ( i , Some ( node ) ) ; } } } // Switch the epoch so that we can track when existing readers have finished. let epoch = { let mut read_counts = self . skip_list . read_counts . lock ( ) . unwrap ( ) ; let epoch = read_counts . epoch ; read_counts . epoch = 1 - epoch ; epoch } as usize ; // Now we need to wait for the old readers to finish. poll_fn ( | cx | { let mut read_counts = self . skip_list . read_counts . lock ( ) . unwrap ( ) ; if read_counts . counts [ epoch ] == 0 { Poll :: Ready ( ( ) ) } else { read_counts . waker = Some ( cx . waker ( ) . clone ( ) ) ; Poll :: Pending } } ) . await ; // Now we can free the memory for the erased items. let end = self . prev_pointers [ 0 ] . get_ptr ( 0 ) ; loop { match maybe_erase { Some ( node ) if node as * const _ != end => { maybe_erase = self . skip_list . free_node ( node ) } _ => break , } } }
Commit splices the new insertion chain into the list.
Commit splices the new insertion chain into the list .
&mut self
&mut self