2 releases
0.1.5 | Apr 15, 2024 |
---|---|
0.1.4 | Aug 26, 2022 |
#197 in Concurrency
312 downloads per month
47KB
747 lines
rose_bloom
rose_bloom
is a crate for passing out references that won't move when you push to it. It is also thread-safe, so you can use it as a concurrent queue if you don't care about freeing memory as you go along. It is lock-free.
Many operations are O(lg n). This will still be extremely fast.
Example
use rose_bloom::Rose;
let rose = Rose::new();
let out1 = rose.push(1);
rose.push(2);
rose.push(3);
println!("{out1}"); // 1
Installation
Add this to your Cargo.toml:
[dependencies]
rose_bloom = "0.1"
#![no_std]
This crate is #![no_std]
but does require alloc
.
Licenses
lib.rs
:
This library provides the Rose
type, a data structure with stable pointers.
It is also concurrent and lock-free. The concurrency was a secondary goal of this project, but you can't have a safe API that is useful without Atomics, and it is more useful regardless.
Example
use rose_bloom::Rose;
let rose = Rose::new();
let out1 = rose.push(1);
rose.push(2);
rose.push(3);
println!("{out1}"); // 1
Compare this to the same code with a [Vec], which does not compile and should not compile:
let mut vect = Vec::new();
vect.push(1);
let out1 = &vect[0];
vect.push(2);
vect.push(3);
println!("{out1}");