Crates.io | bondi |
lib.rs | bondi |
version | 0.1.2 |
source | src |
created_at | 2021-01-09 10:19:11.493624 |
updated_at | 2021-01-11 17:25:06.595871 |
description | Single producer, multi consumer lock-free ring buffer (experimental) |
homepage | |
repository | https://github.com/blasrodri/bondi |
max_upload_size | |
id | 336146 |
size | 13,737 |
Bondi is yet another attempt of producing a lock-free, bounded, single-producer, multi-consumer data structure.
Note: this is an experimental project. Expect things to break, and change.
// initialize a writer and two readers
// send 100 `Message`s, and receive them from different threads
struct Message(usize)
fn main() {
let bondi = Bondi::new(100);
let writer = bondi.get_tx().unwrap();
let reader = bondi.get_rx().unwrap();
let reader2 = bondi.get_rx().unwrap();
std::thread::spawn(move || {
for i in 0..100 {
writer.write(Message(i));
}
});
std::thread::spawn(move || {
let _ = reader.read();
});
std::thread::spawn(move || {
let _ = reader2.read();
}).join().unwrap();
}