pub struct Sender<T> { /* private fields */ }Expand description
The sending side of the spsc queue.
Implementations§
Source§impl<T> Sender<T>
impl<T> Sender<T>
Sourcepub fn try_send(&mut self, data: T) -> Result<(), SendError<T>>
pub fn try_send(&mut self, data: T) -> Result<(), SendError<T>>
Attempts to send a value to the queue without blocking.
Because this queue has a fixed capacity, sending returns SendError::NoSpaceLeft
instead of blocking or growing the buffer when the queue is full.
Returns SendError::ReceiverSideDropped if the Receiver has been dropped.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the total number of items that the queue can hold at most.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of items in the queue.
§WARNING
This length is only a best-effort estimate. It is computed from relaxed atomic and is NOT a linearizable value. It may be temporarily incorrect (including over/under-counting) due to reordering and visibility delays across threads.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the queue is empty.
§WARNING
This length is only a best-effort estimate. It is computed from relaxed atomic and is NOT a linearizable value. It may be temporarily incorrect (including over/under-counting) due to reordering and visibility delays across threads.