pub struct Producer<T> { /* private fields */ }
Expand description
A handle to the queue which allows adding values onto the buffer
Implementations
sourceimpl<T> Producer<T>
impl<T> Producer<T>
sourcepub fn push(&self, v: T)
pub fn push(&self, v: T)
Push a value onto the buffer.
If the buffer is non-full, the operation will execute immediately. If the buffer is full,
this method will block until the buffer is non-full. The waiting strategy is a simple
spin-wait. If you do not want a spin-wait burning CPU, you should call try_push()
directly and implement a different waiting strategy.
sourcepub fn try_push(&self, v: T) -> Option<T>
pub fn try_push(&self, v: T) -> Option<T>
Attempt to push a value onto the buffer.
This method does not block. If the queue is not full, the value will be added to the
queue and the method will return None
, signifying success. If the queue is full,
this method will return Some(v)``, where
v` is your original value.
sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the total capacity of this queue
This value represents the total capacity of the queue when it is full. It does not
represent the current usage. For that, call size()
.
sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Returns the current size of the queue
This value represents the current size of the queue. This value can be from 0-capacity
inclusive.
sourcepub fn free_space(&self) -> usize
pub fn free_space(&self) -> usize
Returns the available space in the queue
This value represents the number of items that can be pushed onto the queue before it becomes full.
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for Producer<T>
impl<T> !Sync for Producer<T>
impl<T> Unpin for Producer<T>
impl<T> !UnwindSafe for Producer<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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