[][src]Struct deadqueue::resizable::Queue

pub struct Queue<T> { /* fields omitted */ }

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 resizable feature in your Cargo.toml

Methods

impl<T> Queue<T>[src]

pub fn new(max_size: usize) -> Self[src]

Create new empty queue

pub async fn pop<'_>(&'_ self) -> T[src]

Get an item from the queue. If the queue is currently empty this method blocks until an item is available.

pub fn try_pop(&self) -> Option<T>[src]

Try to get an item from the queue. If the queue is currently empty return None instead.

pub async fn push<'_>(&'_ self, item: T)[src]

Push an item into the queue

pub fn try_push(&self, item: T) -> Result<(), T>[src]

Try to push an item to the queue. If the queue is currently full return the object as Err<T>.

pub fn capacity(&self) -> usize[src]

Get capacity of the queue

pub fn len(&self) -> usize[src]

Get current length of queue

pub fn available(&self) -> isize[src]

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.

pub async fn resize<'_>(&'_ mut self, new_max_size: usize)[src]

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

impl<T> FromIterator<T> for Queue<T>[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.