quickring
This library provides a very fast, lock-free SPSC ring buffer implementation in Rust.
It can perform 1 billion writes and reads in ~1.76s on my MacBook Air M2,
on usize data with a capacity of 8192.
Features
- Very high performance.
- Generic over any data type.
- Compile-time static capacity.
- Split into producer and consumer (SPSC) for concurrent use.
Usage
Run cargo add quickring to add it to your project, or add the following to your Cargo.toml:
[]
= "*"
Then, you can use it as follows:
use RingBuffer;
const OPERATIONS: usize = 1_000_000;
const CAPACITY: usize = 1 << 13; // 8192
let rb: = new;
let = rb.split;
// Create a producer thread
let producer = spawn;
// Create a consumer thread
let consumer = spawn;
producer.join.unwrap;
consumer.join.unwrap;