pub struct Receiver<T, const N: usize> { /* private fields */ }Expand description
The receiving end of this batching queue
Since this is a single-consume queue, this handle cannot be cloned or shared. Dropping this handle will eventually lead to the sender signaling that this queue has been closed. Items that were in flight will be dropped.
Implementations§
Source§impl<T, const N: usize> Receiver<T, N>
impl<T, const N: usize> Receiver<T, N>
Sourcepub fn try_recv_batch(&mut self) -> Result<Vec<T>, TryRecvError>
pub fn try_recv_batch(&mut self) -> Result<Vec<T>, TryRecvError>
Check if a batch is currently available and fill them into a fresh Vec
If no batch is available it returns TryRecvError::Empty. If no batch will
ever become available because the sender has been dropped it returns
TryRecvError::Closed.
If the next thing you’ll do is to iterate over the vector, prefer
try_recv instead to save one allocation.
Sourcepub fn try_recv(&mut self) -> Result<BucketIter<'_, T, N>, TryRecvError>
pub fn try_recv(&mut self) -> Result<BucketIter<'_, T, N>, TryRecvError>
Check if a batch is currently available and return an iterator of its items
If no batch is available it returns TryRecvError::Empty. If no batch will
ever become available because the sender has been dropped it returns
TryRecvError::Closed.
See recv for more information on the returned iterator.
Sourcepub fn recv(&mut self) -> ReceiveFuture<'_, T, N> ⓘ
pub fn recv(&mut self) -> ReceiveFuture<'_, T, N> ⓘ
A Future that will wait for the next batch and return an iterator of its items
The iterator should be consumed quickly since it borrows the queue bucket that holds the items, meaning that the queue space is not handed back to the sender until the iterator is dropped.