This is a concurrent linked list implementation in Rust using RcuCell.
There are two types of linked list: SignleLinkedList and DoubleLinkedList.
The SingleLinkedList supports the following operations:
front: Get the head entry of list.back: Get the tail entry of list.push_front: Insert a new element into the head of list.pop_front: Remove the element from the head of list.push_back: Insert a new element into the tail of list.iter: Iterate over the list.
each Entry that returned by instert operations could do the following operations:
deref: Read the value of the current element.
The DoubleLinkedList supports the following operations:
front: Get the head entry of list.back: Get the tail entry of list.push_front: Insert a new element into the head of list.pop_front: Remove the element from the head of list.push_back: Insert a new element into the tail of list.pop_back: Remove the element from the tail of list.iter: Iterate over the list.
each Entry that returned by insert operations could do the following operations:
remove: Remove the current element from the list.replace: Replace the current element from the list.insert_after: Insert an element after the entry.insert_ahead: Insert an element ahead the entry.remove_after: Remove the element after the entry.remove_ahead: Remove the element ahead the entry.deref: Read the value of the current element.is_removed: Check if the element is removed from the list.next: Get the next entry in the list.
Any write operations like insert/remove on a removed Entry would just fail.
But it's safe to read(deref) the value of a removed Entry.
push_fronthas better performance thanpush_back, because it doesn't need to lock the previous element.pop_fronthas better performance thanpop_back, because it doesn't need to lock the previous element.pop_backcould result more efficient memory recycle thanpop_front, because it less likely hold the next element.push_frontandpush_backonly need to lock one element.pop_frontandpop_backneed to lock two elements.- Don't hold an
Entryfor a long time, the drop may recursively drop next elements and cause a stack overflow.