pub struct Queue<T> { /* private fields */ }
Expand description
FIFO queue with async pop.
Implementations
sourceimpl<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>ⓘNotable traits for Pop<'a, T>impl<'a, T> Future for Pop<'a, T> type Output = T;
pub fn pop(&self) -> Pop<'_, T>ⓘNotable traits for Pop<'a, T>impl<'a, T> Future for Pop<'a, T> type Output = 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.
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for Queue<T>
impl<T> !Send for Queue<T>
impl<T> !Sync for Queue<T>
impl<T> Unpin for Queue<T>where
T: Unpin,
impl<T> !UnwindSafe for Queue<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more