Skip to main content

RcuIntrusiveList

Struct RcuIntrusiveList 

Source
pub struct RcuIntrusiveList<T, A: RcuListAdapter<T>> { /* private fields */ }

Implementations§

Source§

impl<T, A: RcuListAdapter<T>> RcuIntrusiveList<T, A>

Source

pub fn is_empty(&self, scope: &RcuReadScope) -> bool

Returns whether the list is currently empty without dereferencing any node links.

Source

pub unsafe fn push_front<'a>( &self, scope: &'a RcuReadScope, data: RcuPtrRef<'a, T>, )

Pushes a new element to the front of the list.

Properly initializes link.prev to null and link.next to the former head (or null if the list was empty) before publishing the node to head. This ensures that nodes previously removed from other lists do not retain poisoned or stale pointers.

Note: Re-inserting a previously removed node overwrites its link.next pointer. List iteration and re-insertion must be synchronized (e.g., via an external lock or by waiting for an RCU grace period after removal); otherwise a concurrent iterator still visiting the node may observe wrong results (such as skipping/repeating elements or continuing into the destination list).

§Safety
  • Requires external synchronization to exclude concurrent writers.
  • data must be non-null, properly aligned, and point to a valid, initialized T that outlives its membership in the list and any subsequent RCU reader grace period.
  • data must not currently be attached to any list.
Source

pub unsafe fn push_back<'a>( &self, scope: &'a RcuReadScope, data: RcuPtrRef<'a, T>, )

Pushes a new element to the back of the list.

Properly initializes link.next to null and link.prev to the former tail (or null if the list was empty) before publishing the node. This ensures that nodes previously removed from other lists do not retain poisoned or stale pointers.

Note: Re-inserting a previously removed node overwrites its link.next pointer. List iteration and re-insertion must be synchronized (e.g., via an external lock or by waiting for an RCU grace period after removal); otherwise a concurrent iterator still visiting the node may observe wrong results (such as skipping/repeating elements or continuing into the destination list).

§Safety
  • Requires external synchronization to exclude concurrent writers.
  • data must be non-null, properly aligned, and point to a valid, initialized T that outlives its membership in the list and any subsequent RCU reader grace period.
  • data must not currently be attached to any list.
Source

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.

Source

pub unsafe fn remove<'a>( &self, scope: &'a RcuReadScope, node: RcuPtrRef<'a, T>, ) -> RcuPtrRef<'a, Link>

Removes the given node from the list.

Returns the link of the next node in the list, if any.

Concurrent readers may continue to see this entry in the list until the RCU state machine has made sufficient progress to ensure that no concurrent readers are holding read guards. If the removed node is re-inserted into a list, list iteration and re-insertion must be synchronized; otherwise concurrent iterators still visiting node may observe wrong results.

§Safety
  • Requires external synchronization to exclude concurrent writers.
  • node must be non-null, properly aligned, and point to a valid, initialized T currently attached to self.
  • The removed node must not be dropped while concurrent RCU readers may still be visiting it (e.g., wait for an RCU grace period before dropping).
Source

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.

Source

pub unsafe fn update(&self, scope: &RcuReadScope, other: Self)

Updates the list with the contents of another list.

Any elements previously in self are replaced in place without poisoning their Link::prev pointers; call clear first if those elements need to be re-attached to a list later.

§Safety

Requires external synchronization to exclude concurrent writers.

Source

pub unsafe fn clear<'a>( &self, scope: &'a RcuReadScope, callback: impl Fn(RcuPtrRef<'a, T>), )
where T: 'static,

Removes all elements from the list.

The callback is called for each element in the list. The caller is responsible for cleaning up the removed elements.

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. If removed elements are re-inserted into a list, list iteration and re-insertion must be synchronized; otherwise concurrent iterators still visiting those elements may observe wrong results.

§Safety
  • Requires external synchronization to exclude concurrent writers.
  • Removed elements must not be dropped while concurrent RCU readers may still be visiting them (e.g., wait for an RCU grace period before dropping).
Source

pub fn cursor<'a>( &'a self, scope: &'a RcuReadScope, ) -> RcuIntrusiveListCursor<'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.

Source

pub fn iter<'a>(&self, scope: &'a RcuReadScope) -> impl Iterator<Item = &'a T>
where T: 'static,

Returns an iterator over the elements in the list.

Trait Implementations§

Source§

impl<T: Debug, A: Debug + RcuListAdapter<T>> Debug for RcuIntrusiveList<T, A>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, A: RcuListAdapter<T>> Default for RcuIntrusiveList<T, A>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T, A> RcuDroppable for RcuIntrusiveList<T, A>

Auto Trait Implementations§

§

impl<T, A> !Freeze for RcuIntrusiveList<T, A>

§

impl<T, A> RefUnwindSafe for RcuIntrusiveList<T, A>

§

impl<T, A> Send for RcuIntrusiveList<T, A>
where T: Send, A: Send,

§

impl<T, A> Sync for RcuIntrusiveList<T, A>
where T: Sync, A: Sync,

§

impl<T, A> Unpin for RcuIntrusiveList<T, A>
where T: Unpin, A: Unpin,

§

impl<T, A> UnsafeUnpin for RcuIntrusiveList<T, A>

§

impl<T, A> UnwindSafe for RcuIntrusiveList<T, A>
where T: UnwindSafe, A: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.