Struct nolock::queues::spsc::bounded::BoundedSender [−][src]
pub struct BoundedSender<T> { /* fields omitted */ }
Expand description
The Sending-Half for the queue
Implementations
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());
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::WouldBlock)), tx.try_enqueue(13));
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
Auto Trait Implementations
impl<T> !RefUnwindSafe for BoundedSender<T>
impl<T> Unpin for BoundedSender<T>
impl<T> !UnwindSafe for BoundedSender<T>