quickring

Crates.ioquickring
lib.rsquickring
version0.1.0
created_at2026-01-20 13:17:42.301152+00
updated_at2026-01-20 13:17:42.301152+00
descriptionA very fast, lock-free SPSC ring buffer.
homepagehttps://github.com/avhz/quickring
repositoryhttps://github.com/avhz/quickring
max_upload_size
id2056530
size377,966
Amando (avhz)

documentation

README

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:

[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();
Commit count: 12

cargo fmt