pub struct Queue<T> { /* private fields */ }Expand description
Queue that is limited in size and supports resizing.
This queue implementation has the following characteristics:
- Resizable (
deadqueue::resizable::Queue) - Based on
deadqueue::unlimited::Queue - Has limited capacity with back pressure on push
- Supports resizing
- Enabled via the
resizablefeature in yourCargo.toml
Implementations
sourceimpl<T> Queue<T>
impl<T> Queue<T>
sourcepub async fn pop(&self) -> T
pub async fn pop(&self) -> T
Get an item from the queue. If the queue is currently empty this method blocks until an item is available.
sourcepub fn try_pop(&self) -> Option<T>
pub fn try_pop(&self) -> Option<T>
Try to get an item from the queue. If the queue is currently empty return None instead.
sourcepub fn try_push(&self, item: T) -> Result<(), T>
pub fn try_push(&self, item: T) -> Result<(), T>
Try to push an item to the queue. If the queue is currently
full return the object as Err<T>.
sourcepub fn available(&self) -> isize
pub fn available(&self) -> isize
The number of available items in the queue. If there are no items in the queue this number can become negative and stores the number of futures waiting for an item.
sourcepub async fn resize(&mut self, new_max_size: usize)
pub async fn resize(&mut self, new_max_size: usize)
Resize queue. This increases or decreases the queue capacity accordingly.
Note: Increasing the capacity of a queue happens without blocking unless a resize operation is already in progress. Decreasing the capacity can block if there are futures waiting to push items to the queue.
Trait Implementations
sourceimpl<T> FromIterator<T> for Queue<T>
impl<T> FromIterator<T> for Queue<T>
sourcefn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
Auto Trait Implementations
impl<T> !RefUnwindSafe for Queue<T>
impl<T> Send for Queue<T> where
T: Send,
impl<T> Sync for Queue<T> where
T: Send,
impl<T> Unpin for Queue<T> where
T: Unpin,
impl<T> !UnwindSafe for Queue<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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