Crate cueue

Source
Expand description

A high performance, single-producer, single-consumer, bounded circular buffer of contiguous elements, that supports lock-free atomic batch operations, suitable for inter-thread communication.

 let (mut w, mut r) = cueue::cueue(1 << 20).unwrap();

 let buf = w.write_chunk();
 assert!(buf.len() >= 9);
 buf[..9].copy_from_slice(b"foobarbaz");
 w.commit(9);

 let read_result = r.read_chunk();
 assert_eq!(read_result, b"foobarbaz");
 r.commit();

Elements in the queue are always initialized, and not dropped until the queue is dropped. This allows re-use of elements (useful for elements with heap allocated contents), and prevents contention on the senders heap (by avoiding the consumer freeing memory the sender allocated).

Structs§

Reader
Reader of a Cueue.
Writer
Writer of a Cueue.

Functions§

cueue
Create a single-producer, single-consumer Cueue.
cueue_in_fd
Like cueue, but takes a file descriptor f, to put the queue into.