pub struct Queue<T> { /* private fields */ }Expand description
FIFO queue with optional bound; cloning shares the queue.
Implementations§
Source§impl<T> Queue<T>
impl<T> Queue<T>
pub fn unbounded() -> Queue<T>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn has_space(&self) -> bool
pub fn has_space(&self) -> bool
Is there room right now? (Zero time; the answer can go stale as soon as another task runs.)
pub fn try_put(&self, item: T) -> Result<(), T>
pub fn try_get(&self) -> Option<T>
pub fn put(&self, item: T) -> Put<T> ⓘ
pub fn get(&self) -> Get<T> ⓘ
Sourcepub fn wait_for_space(&self) -> Space<T> ⓘ
pub fn wait_for_space(&self) -> Space<T> ⓘ
Wait until the queue has room, without handing over an item.
For callers that must do something with the item at the instant it is
accepted — a TLM FIFO’s analysis tap, which broadcasts each item as it
goes in. put takes ownership, so by the time it returns there is
nothing left to show anyone; this splits the wait from the handover:
ⓘ
q.wait_for_space().await;
tap(&item); // no await between these two lines, so no
let _ = q.try_put(item); // other task can take the space firstTrait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Queue<T>
impl<T> !Send for Queue<T>
impl<T> !Sync for Queue<T>
impl<T> !UnwindSafe for Queue<T>
impl<T> Freeze for Queue<T>
impl<T> Unpin for Queue<T>
impl<T> UnsafeUnpin for Queue<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more