From 58d96fbea3cfedb1155668d3180582cc65fcc264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Thu, 3 Oct 2024 16:15:05 +0200 Subject: [PATCH] Rename Node parent to next --- milli/src/update/new/append_only_linked_list.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/milli/src/update/new/append_only_linked_list.rs b/milli/src/update/new/append_only_linked_list.rs index 697d5583f..274d3eea4 100644 --- a/milli/src/update/new/append_only_linked_list.rs +++ b/milli/src/update/new/append_only_linked_list.rs @@ -8,7 +8,7 @@ pub struct AppendOnlyLinkedList { struct Node { item: T, - parent: AtomicPtr>, + next: AtomicPtr>, } impl AppendOnlyLinkedList { @@ -22,12 +22,12 @@ impl AppendOnlyLinkedList { pub fn push(&self, item: T) -> &mut T { use std::sync::atomic::Ordering::{Relaxed, SeqCst}; - let node = Box::leak(Box::new(Node { item, parent: AtomicPtr::default() })); + let node = Box::leak(Box::new(Node { item, next: AtomicPtr::default() })); let mut head = self.head.load(SeqCst); loop { std::hint::spin_loop(); - node.parent = AtomicPtr::new(head); + node.next = AtomicPtr::new(head); match self.head.compare_exchange_weak(head, node, SeqCst, Relaxed) { Ok(_) => break, Err(new) => head = new, @@ -77,8 +77,8 @@ impl Iterator for IntoIter { None } else { let node = unsafe { Box::from_raw(ptr) }; - // Let's set the next node to read to be the parent of this one - self.0 = node.parent; + // Let's set the next node to read to be the next of this one + self.0 = node.next; Some(node.item) } } @@ -89,8 +89,8 @@ impl Drop for IntoIter { let mut ptr = *self.0.get_mut(); while !ptr.is_null() { let mut node = unsafe { Box::from_raw(ptr) }; - // Let's set the next node to read to be the parent of this one - ptr = *node.parent.get_mut(); + // Let's set the next node to read to be the next of this one + ptr = *node.next.get_mut(); } } }