pub struct RcuList<T: Send + Sync + 'static, A: RcuListAdapter<T>> { /* private fields */ }Expand description
An RcuList is a doubly-linked list that supports concurrent access via
read-copy-update (RCU) synchronization.
An RcuList can be safely read by multiple readers, even while a writer
is modifying the list. To read from the list, you will need to enter an
RcuReadScope.
To modify the list, you will need to use some external synchronization,
such as a Mutex, to exclude concurrent writers.
Implementations§
Source§impl<T: Send + Sync + 'static, A: RcuListAdapter<T>> RcuList<T, A>
impl<T: Send + Sync + 'static, A: RcuListAdapter<T>> RcuList<T, A>
Sourcepub fn new(head: RcuPtr<Link>, tail: RcuPtr<Link>) -> Self
pub fn new(head: RcuPtr<Link>, tail: RcuPtr<Link>) -> Self
Creates a new list with the given head and tail.
Sourcepub unsafe fn push_front<'a>(
&self,
scope: &'a RcuReadScope,
data: T,
) -> RcuPtrRef<'a, T>
pub unsafe fn push_front<'a>( &self, scope: &'a RcuReadScope, data: T, ) -> RcuPtrRef<'a, T>
Pushes a new element to the front of the list.
§Safety
Requires external synchronization to exclude concurrent writers.
Sourcepub unsafe fn push_back<'a>(
&self,
scope: &'a RcuReadScope,
data: T,
) -> RcuPtrRef<'a, T>
pub unsafe fn push_back<'a>( &self, scope: &'a RcuReadScope, data: T, ) -> RcuPtrRef<'a, T>
Pushes a new element to the back of the list.
§Safety
Requires external synchronization to exclude concurrent writers.
Sourcepub unsafe fn append(&self, scope: &RcuReadScope, other: Self)
pub unsafe fn append(&self, scope: &RcuReadScope, other: Self)
Appends another list to the end of this list.
§Safety
Requires external synchronization to exclude concurrent writers.
Sourcepub unsafe fn split_off(&self, scope: &RcuReadScope, pos: usize) -> Self
pub unsafe fn split_off(&self, scope: &RcuReadScope, pos: usize) -> Self
Splits the list into two lists at the given position.
If the given position is past the end of the list, returns an empty list.
§Safety
Requires external synchronization to exclude concurrent writers.
Sourcepub unsafe fn clear(&self)
pub unsafe fn clear(&self)
Removes all elements from the list.
Concurrent readers may continue to see the old value of the list until the RCU state machine has made sufficient progress to ensure that no concurrent readers are holding read guards.
§Safety
Requires external synchronization to exclude concurrent writers.
Sourcepub fn cursor<'a>(&'a self, scope: &'a RcuReadScope) -> RcuListCursor<'a, T, A>
pub fn cursor<'a>(&'a self, scope: &'a RcuReadScope) -> RcuListCursor<'a, T, A>
Returns a cursor that can be used to traverse and modify the list.
Concurrent readers may continue to see the old value of the list until the RCU state machine has made sufficient progress to ensure that no concurrent readers are holding read guards.
Sourcepub fn iter<'a>(&self, scope: &'a RcuReadScope) -> impl Iterator<Item = &'a T>
pub fn iter<'a>(&self, scope: &'a RcuReadScope) -> impl Iterator<Item = &'a T>
Returns an iterator over the elements in the list.