pub struct SpscRingBuffer;Expand description
Factory for creating producer/consumer pairs.
Implementations§
Source§impl SpscRingBuffer
impl SpscRingBuffer
Sourcepub fn new<T>(capacity: usize) -> (Producer<T>, Consumer<T>)
pub fn new<T>(capacity: usize) -> (Producer<T>, Consumer<T>)
Creates a new SPSC ring buffer with the given capacity.
The actual capacity will be rounded up to the next power of 2.
Returns a (Producer, Consumer) pair for inter-thread communication.
§Examples
use bbx_core::spsc::SpscRingBuffer;
let (mut producer, mut consumer) = SpscRingBuffer::new::<i32>(4);
producer.try_push(42).unwrap();
assert_eq!(consumer.try_pop(), Some(42));Auto Trait Implementations§
impl Freeze for SpscRingBuffer
impl RefUnwindSafe for SpscRingBuffer
impl Send for SpscRingBuffer
impl Sync for SpscRingBuffer
impl Unpin for SpscRingBuffer
impl UnwindSafe for SpscRingBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more