tokio::runtime::task::list

Type Alias List

Source
type List<S> = ShardedList<Task<S>, <Task<S> as Link>::Target>;

Aliased Type§

struct List<S> {
    lists: Box<[Mutex<LinkedList<Task<S>, Header>>]>,
    added: MetricAtomicU64,
    count: MetricAtomicUsize,
    shard_mask: usize,
}

Fields§

§lists: Box<[Mutex<LinkedList<Task<S>, Header>>]>§added: MetricAtomicU64§count: MetricAtomicUsize§shard_mask: usize

Implementations

Source§

impl<L: ShardedListItem> ShardedList<L, L::Target>

Source

pub(crate) fn pop_back(&self, shard_id: usize) -> Option<L::Handle>

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

Source

pub(crate) unsafe fn remove( &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.
Source

pub(crate) fn lock_shard(&self, val: &L::Handle) -> ShardGuard<'_, L, L::Target>

Gets the lock of ShardedList, makes us have the write permission.

Source

pub(crate) fn len(&self) -> usize

Gets the count of elements in this list.

Source

pub(crate) fn added(&self) -> u64

Gets the total number of elements added to this list.

Source

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

Returns whether the linked list does not contain any node.

Source

pub(crate) fn shard_size(&self) -> usize

Gets the shard size of this SharedList.

Used to help us to decide the parameter shard_id of the pop_back method.

Source

fn shard_inner( &self, id: usize, ) -> MutexGuard<'_, LinkedList<L, <L as Link>::Target>>

Source§

impl<L, T> ShardedList<L, T>

Source

pub(crate) fn new(sharded_size: usize) -> Self

Creates a new and empty sharded linked list with the specified size.