| Crates.io | quickring |
| lib.rs | quickring |
| version | 0.1.0 |
| created_at | 2026-01-20 13:17:42.301152+00 |
| updated_at | 2026-01-20 13:17:42.301152+00 |
| description | A very fast, lock-free SPSC ring buffer. |
| homepage | https://github.com/avhz/quickring |
| repository | https://github.com/avhz/quickring |
| max_upload_size | |
| id | 2056530 |
| size | 377,966 |
quickringThis 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.
Run cargo add quickring to add it to your project, or add the following to your Cargo.toml:
[dependencies]
quickring = "*"
Then, you can use it as follows:
use quickring::RingBuffer;
const OPERATIONS: usize = 1_000_000;
const CAPACITY: usize = 1 << 13; // 8192
let rb: RingBuffer<usize, CAPACITY> = RingBuffer::new();
let (mut tx, mut rx) = rb.split();
// Create a producer thread
let producer = std::thread::spawn(move || {
for i in 0..OPERATIONS {
while !tx.push(i) {}
}
});
// Create a consumer thread
let consumer = std::thread::spawn(move || {
for _ in 0..OPERATIONS {
loop {
if let Some(_) = rx.pop() {
break;
}
}
}
});
producer.join().unwrap();
consumer.join().unwrap();