Crates.io | rt-history |
lib.rs | rt-history |
version | 3.0.0 |
source | src |
created_at | 2021-11-17 08:33:57.02142 |
updated_at | 2023-07-31 07:12:10.125558 |
description | An RT-safe history log with error checking |
homepage | |
repository | https://github.com/HadrienG2/rt-history |
max_upload_size | |
id | 483211 |
size | 53,073 |
This is a bounded wait-free thread synchronization primitive which allows you to record the time evolution of some data on one thread and be able to query the last N data points on other threads.
By definition of wait-free synchronization, the producer and consumer threads cannot wait for each other, so in bad conditions (too small a buffer size, too low a thread's priority, too loaded a system...), two race conditions can occur:
let (mut input, output) = RTHistory::<u8>::new(8).split();
let in_buf = [1, 2, 3];
input.write(&in_buf[..]);
let mut out_buf = [0; 3];
assert_eq!(output.read(&mut out_buf[..]), Ok(3));
assert_eq!(in_buf, out_buf);