Skip to main content

new

Function new 

Source
pub fn new(capacity: usize) -> (Producer, Consumer)
Expand description

Creates a new SPSC ring buffer with the given capacity.

Capacity is rounded up to the next power of two. Returns a (Producer, Consumer) pair.

§Panics

Panics if capacity is zero.

§Examples

let (p, c) = rt_ring::new(4);
p.push(1.0);
p.push(2.0);
assert_eq!(c.pop(), Some(1.0));
assert_eq!(c.pop(), Some(2.0));
assert_eq!(c.pop(), None);