#lock-free-queue #multi-consumer #multi-producer #producer-consumer #real-time #bounded

atomic-queue

Simple bounded lock-free queue for use in Audio applications, ported from https://github.com/max0x7ba/atomic_queue

8 releases (4 stable)

2.2.0 Aug 13, 2024
2.1.0 Jan 17, 2024
2.0.0 Dec 7, 2023
1.0.1 Sep 22, 2022
0.1.0 Jul 9, 2021

#627 in Audio

Download history 6/week @ 2024-07-22 99/week @ 2024-07-29 24/week @ 2024-08-05 172/week @ 2024-08-12 25/week @ 2024-08-19 49/week @ 2024-08-26 16/week @ 2024-09-02 8/week @ 2024-09-09 22/week @ 2024-09-16 43/week @ 2024-09-23 17/week @ 2024-09-30 1/week @ 2024-10-07 38/week @ 2024-10-14 2/week @ 2024-10-21 8/week @ 2024-10-28 24/week @ 2024-11-04

72 downloads per month
Used in 2 crates

MIT license

205KB
351 lines

atomic-queue

crates.io docs.rs


Multi-producer multi-consumer bounded lock-free queue for use in Audio applications, ported from https://github.com/max0x7ba/atomic_queue.

Quite a bit slower than ringbuf (~2x) on i7.

I'd think this is fine since this queue supporting multiple consumers and multiple producers while ringbuf is single producer single consumer.

30% faster on a M1 Pro Macbook.

License

MIT


lib.rs:

atomic_queue is a port of C++'s max0x7ba/atomic_queue implementation to rust.

This is part of augmented-audio.

It provides a bounded multi-producer, multi-consumer lock-free queue that is real-time safe.

Usage

let queue: atomic_queue::Queue<usize> = atomic_queue::bounded(10);

queue.push(10);
if let Some(v) = queue.pop() {
    assert_eq!(v, 10);
}

Safety

This queue implementation uses unsafe internally.

Performance

When benchmarked on a 2017 i7, this was a lot slower than ringbuf (~2x).

I'd think this is fine since this queue supporting multiple consumers and multiple producers while ringbuf is single producer single consumer.

Testing again on a M1 Pro, it is 30% faster.

No runtime deps