pub struct PriorityQueue<T> { /* private fields */ }
Expand description
An async-aware priority queue.
Implementations§
Source§impl<T: Ord> PriorityQueue<T>
impl<T: Ord> PriorityQueue<T>
pub fn new() -> Self
Sourcepub fn push(&self, item: T)
pub fn push(&self, item: T)
Pushes an item into the queue. It will be removed in an order consistent with the ordering of itself relative to other items in the queue at the time of removal.
Sourcepub fn try_pop(&self) -> Option<T>
pub fn try_pop(&self) -> Option<T>
Attempts to remove the item with the highest priority from the queue, returning None
if
there are no available items.
Sourcepub fn pop(&self) -> PopFut<'_, T> ⓘ
pub fn pop(&self) -> PopFut<'_, T> ⓘ
Removes the item with the highest priority from the queue, waiting for an item should there not be one immediately available.
Items are removed from the queue on a ‘first come, first served’ basis.
Sourcepub fn incoming(&self) -> IncomingStream<'_, T>
pub fn incoming(&self) -> IncomingStream<'_, T>
Returns a stream of highest-priority items from this queue.
Items are removed from the queue on a ‘first come, first served’ basis.
Sourcepub fn pending(&self) -> impl Iterator<Item = T> + '_
pub fn pending(&self) -> impl Iterator<Item = T> + '_
Returns an iterator of pending items from the queue (i.e: those that have already been inserted). Items will only be removed from the queue as the iterator is advanced.
Sourcepub fn drain(&self) -> impl ExactSizeIterator<Item = T> + FusedIterator
pub fn drain(&self) -> impl ExactSizeIterator<Item = T> + FusedIterator
Returns an iterator of items currently occupying the queue, immediately draining the queue.