pub struct Queue<T> { /* private fields */ }Expand description
Queue that is limited in size and does not support resizing.
This queue implementation has the following characteristics:
- Based on
crossbeam_queue::ArrayQueue - Has limit capacity with back pressure on push
- Does not support resizing
- Enabled via the
limitedfeature in yourCargo.toml
Implementations§
Source§impl<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 into the queue. If the queue is full
the item is returned as Err<T>.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Get capacity of the queue (maximum number of items queue can store)
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 fn subscribe_full(&self) -> Receiver
pub fn subscribe_full(&self) -> Receiver
Get a Receiver object that can repeatedly be awaited for
queue-full notifications.
Sourcepub async fn wait_empty(&self)
pub async fn wait_empty(&self)
Await until the queue is empty.
Sourcepub fn subscribe_empty(&self) -> Receiver
pub fn subscribe_empty(&self) -> Receiver
Get a Receiver object that can repeatedly be awaited for
queue-empty notifications.