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>
impl<L, T> LinkedList<L, T>
sourcepub(crate) const fn new() -> LinkedList<L, T>
pub(crate) const fn new() -> LinkedList<L, T>
Creates an empty linked list.
source§impl<L: Link> LinkedList<L, L::Target>
impl<L: Link> LinkedList<L, L::Target>
sourcepub(crate) fn push_front(&mut self, val: L::Handle)
pub(crate) fn push_front(&mut self, val: L::Handle)
Adds an element first in the list.
sourcepub(crate) fn pop_front(&mut self) -> Option<L::Handle>
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.
sourcepub(crate) fn pop_back(&mut self) -> Option<L::Handle>
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.
sourcepub(crate) fn is_empty(&self) -> bool
pub(crate) fn is_empty(&self) -> bool
Returns whether the linked list does not contain any node
sourcepub(crate) unsafe fn remove(
&mut self,
node: NonNull<L::Target>,
) -> Option<L::Handle>
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 byself
,node
is not contained by any list,node
is currently contained by some otherGuardedLinkedList
and the caller has an exclusive access to that list. This condition is used by the linked list insync::Notify
.
source§impl<T: Link> LinkedList<T, T::Target>
impl<T: Link> LinkedList<T, T::Target>
pub(crate) fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<'_, T, F> ⓘ
source§impl<L: Link> LinkedList<L, L::Target>
impl<L: Link> LinkedList<L, L::Target>
sourcepub(crate) fn into_guarded(
self,
guard_handle: L::Handle,
) -> GuardedLinkedList<L, L::Target>
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.