Struct tokio::util::linked_list::LinkedList

source ·
pub(crate) struct LinkedList<L, T> {
    head: Option<NonNull<T>>,
    tail: Option<NonNull<T>>,
    _marker: PhantomData<*const L>,
}
Expand description

An intrusive linked list.

Currently, the list is not emptied on drop. It is the caller’s responsibility to ensure the list is empty before dropping it.

Fields§

§head: Option<NonNull<T>>

Linked list head

§tail: Option<NonNull<T>>

Linked list tail

§_marker: PhantomData<*const L>

Node type marker.

Implementations§

source§

impl<L, T> LinkedList<L, T>

source

pub(crate) const fn new() -> LinkedList<L, T>

Creates an empty linked list.

source§

impl<L: Link> LinkedList<L, L::Target>

source

pub(crate) fn push_front(&mut self, val: L::Handle)

Adds an element first in the list.

source

pub(crate) fn pop_front(&mut self) -> Option<L::Handle>

Removes the first element from a list and returns it, or None if it is empty.

source

pub(crate) fn pop_back(&mut self) -> Option<L::Handle>

Removes the last element from a list and returns it, or None if it is empty.

source

pub(crate) fn is_empty(&self) -> bool

Returns whether the linked list does not contain any node

source

pub(crate) unsafe fn remove( &mut self, node: NonNull<L::Target>, ) -> Option<L::Handle>

Removes the specified node from the list

§Safety

The caller must ensure that exactly one of the following is true:

  • node is currently contained by self,
  • node is not contained by any list,
  • node is currently contained by some other GuardedLinkedList and the caller has an exclusive access to that list. This condition is used by the linked list in sync::Notify.
source§

impl<L: Link> LinkedList<L, L::Target>

source

pub(crate) fn last(&self) -> Option<&L::Target>

source§

impl<T: Link> LinkedList<T, T::Target>

source

pub(crate) fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<'_, T, F>
where F: FnMut(&T::Target) -> bool,

source§

impl<L: Link> LinkedList<L, L::Target>

source

pub(crate) fn into_guarded( self, guard_handle: L::Handle, ) -> GuardedLinkedList<L, L::Target>

Turns a linked list into the guarded version by linking the guard node with the head and tail nodes. Like with other nodes, you should guarantee that the guard node is pinned in memory.

Trait Implementations§

source§

impl<L: Link> Debug for LinkedList<L, L::Target>

source§

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

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

impl<L: Link> Default for LinkedList<L, L::Target>

source§

fn default() -> Self

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

impl<L: Link> Send for LinkedList<L, L::Target>
where L::Target: Send,

source§

impl<L: Link> Sync for LinkedList<L, L::Target>
where L::Target: Sync,

Auto Trait Implementations§

§

impl<L, T> Freeze for LinkedList<L, T>

§

impl<L, T> RefUnwindSafe for LinkedList<L, T>

§

impl<L, T> Unpin for LinkedList<L, T>

§

impl<L, T> UnwindSafe for LinkedList<L, T>

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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.