pub struct BoundedSender<T> { /* private fields */ }
Expand description
The Sending-Half for the queue
Implementations
sourceimpl<T> BoundedSender<T>
impl<T> BoundedSender<T>
sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Returns whether or not the Queue has been closed by the Consumer
Example
let (rx, tx) = bounded::queue::<usize>(3);
// Drop the Consumer and therefore also close the Queue
drop(rx);
assert_eq!(true, tx.is_closed());
sourcepub fn try_enqueue(&mut self, data: T) -> Result<(), (T, EnqueueError)>
pub fn try_enqueue(&mut self, data: T) -> Result<(), (T, EnqueueError)>
Attempts to Enqueue the given piece of Data
Example:
Enqueue Data when there is still space
// Create a new Queue with the capacity for 16 Elements
let (mut rx, mut tx) = bounded::queue::<usize>(16);
// Enqueue some Data
assert_eq!(Ok(()), tx.try_enqueue(13));
Enqueue Data when there is no more space
// Create a new Queue with the capacity for 16 Elements
let (mut rx, mut tx) = bounded::queue::<usize>(16);
// Fill up the Queue
for i in 0..16 {
assert_eq!(Ok(()), tx.try_enqueue(i));
}
// Attempt to enqueue some Data, but there is no more room
assert_eq!(Err((13, EnqueueError::Full)), tx.try_enqueue(13));
sourcepub fn enqueue(&mut self, data: T) -> Result<(), (T, EnqueueError)>
pub fn enqueue(&mut self, data: T) -> Result<(), (T, EnqueueError)>
A blocking enqueue Operation. This is obviously not lock-free anymore and will simply spin while trying to enqueue the Data until it works
Trait Implementations
sourceimpl<T> Debug for BoundedSender<T>
impl<T> Debug for BoundedSender<T>
sourceimpl<T> Drop for BoundedSender<T>
impl<T> Drop for BoundedSender<T>
impl<T> Send for BoundedSender<T>
impl<T> Sync for BoundedSender<T>
Auto Trait Implementations
impl<T> !RefUnwindSafe for BoundedSender<T>
impl<T> Unpin for BoundedSender<T>
impl<T> !UnwindSafe for BoundedSender<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more