#lock-free #wait-free #spsc #queue

no-std rtrb

A realtime-safe single-producer single-consumer ring buffer

5 releases

0.2.0 Sep 20, 2021
0.1.4 Jun 4, 2021
0.1.3 Apr 14, 2021
0.1.2 Dec 19, 2020
0.1.1 Nov 20, 2020

#48 in Concurrency

Download history 96/week @ 2021-07-03 267/week @ 2021-07-10 133/week @ 2021-07-17 114/week @ 2021-07-24 212/week @ 2021-07-31 83/week @ 2021-08-07 204/week @ 2021-08-14 185/week @ 2021-08-21 228/week @ 2021-08-28 259/week @ 2021-09-04 243/week @ 2021-09-11 237/week @ 2021-09-18 183/week @ 2021-09-25 268/week @ 2021-10-02 534/week @ 2021-10-09 406/week @ 2021-10-16

737 downloads per month
Used in 19 crates (5 directly)

MIT/Apache

60KB
601 lines

Real-Time Ring Buffer

A wait-free single-producer single-consumer (SPSC) ring buffer for Rust.

This crate can be used without the standard library (#![no_std]) by disabling the std feature (which is enabled by default), but the alloc crate is needed nevertheless.

Usage

Add this to your Cargo.toml:

[dependencies]
rtrb = "0.2"

Breaking Changes

For a list of breaking changes and for instructions how to upgrade between released versions, have a look at the changelog.

Development

Running the tests:

cargo test

Testing the benchmarks (without actually benchmarking):

cargo test --benches

Running the benchmarks (using the criterion crate; results will be available in target/criterion/report/index.html):

cargo bench

Creating the HTML docs (which will be available in target/doc/rtrb/index.html):

cargo doc

Minimum Supported rustc Version

This crate's minimum supported rustc version (MSRV) is 1.36.0. The MSRV is not expected to be updated frequently, but if it is, there will be (at least) a minor version bump.

Origin Story

The initial code has been ripped off of https://github.com/crossbeam-rs/crossbeam/pull/338, with permission of the PR author.

It has been isolated from the rest of crossbeam with git-filter-repo:

git-filter-repo --subdirectory-filter crossbeam-queue --path src/spsc.rs --path tests/spsc.rs --refs refs/heads/spsc

Alternatives

If you don't like this crate, no problem, there are several alternatives for you to choose from. There are many varieties of ring buffers available, here we limit the selection to wait-free SPSC implementations:

There are also implementations in other languages:

If you know more alternatives for this list, please open an issue.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies