| Crates.io | doublebuf |
| lib.rs | doublebuf |
| version | 0.1.0 |
| created_at | 2025-08-15 11:27:38.271885+00 |
| updated_at | 2025-08-15 11:27:38.271885+00 |
| description | Concurrent auto-swapping double buffer |
| homepage | |
| repository | https://github.com/ARogovskyy/doublebuf |
| max_upload_size | |
| id | 1796593 |
| size | 19,718 |
Warning: Until this crate reaches version
1.0it should be considered WIP-grade.
This crate provides a double buffer. Differences to existing implementations:
no_std compatible (needs a critical_section implementation)Usage:
use doublebuf::*;
let mut db: DoubleBuf<u8> = DoubleBuf::new();
let (mut back, mut front) = db.init();
let mut writer = back.write();
let reader = front.read();
// Both are initialized with the default value
assert_eq!(*reader, 0);
assert_eq!(*writer, 0);
*writer = 5;
drop(writer);
drop(reader);
// the buffers are swapped now!
let reader = front.read();
assert_eq!(*reader, 5);