pub struct Queue<T> { /* private fields */ }
Expand description
FIFO queue with async pop.
Implementations§
source§impl<T> Queue<T>
impl<T> Queue<T>
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates new queue with given capacity
.
capacity
must be greater than 0 - it’ll panic otherwise.
sourcepub fn push(&self, element: T)
pub fn push(&self, element: T)
Pushes element
into the queue.
If queue is full it will push out the last (oldest) element out of the queue.
sourcepub fn pop(&self) -> Pop<'_, T> ⓘ
pub fn pop(&self) -> Pop<'_, T> ⓘ
Pops (asynchronously) element off the queue.
It means that if queue is currently empty await
will
wait till element is pushed into the queue.