bbqueue-0.4.0 has been yanked.
BBQueue
BBQueue, short for "BipBuffer Queue", is a Single Producer Single Consumer, lockless, no_std, thread safe, queue, based on BipBuffers. For more info on the design of the lock-free algorithm used by bbqueue, see this blog post.
BBQueue is designed (primarily) to be a First-In, First-Out queue for use with DMA on embedded systems.
While Circular/Ring Buffers allow you to send data between two threads (or from an interrupt to main code), you must push the data one piece at a time. With BBQueue, you instead are granted a block of contiguous memory, which can be filled (or emptied) by a DMA engine.
Local usage
#
# use ;
#
# use ;
#
// Create a buffer with six elements
let bb: = new;
let = bb.try_split.unwrap;
// Request space for one byte
let mut wgr = prod.grant_exact.unwrap;
// Set the data
wgr = 123;
assert_eq!;
// Make the data ready for consuming
wgr.commit;
// Read all available bytes
let rgr = cons.read.unwrap;
assert_eq!;
// Release the space for later writes
rgr.release;
Static usage
#
# use ;
#
# use ;
#
// Create a buffer with six elements
static BB: = BBBuffer;