Crates.io | rcu_128 |
lib.rs | rcu_128 |
version | 0.2.2 |
source | src |
created_at | 2024-06-19 06:48:51.476698 |
updated_at | 2024-06-25 06:17:31.260766 |
description | RCU (Read-Copy-Update) implementation for platforms supporting atomic 128-bit operations. |
homepage | |
repository | https://github.com/cyborg42/rcu_128.git |
max_upload_size | |
id | 1276588 |
size | 17,874 |
Rcu128 is a Rust library that provides a concurrent data structure for read-copy-update (RCU) style access to a value. It allows multiple readers to access the value concurrently while ensuring safe updates by blocking the release of the value until all current readers have finished reading the old value.
Only available on platforms that support atomic loads and stores of u128.
Cargo.toml
[dependencies]
rcu_128 = { git = "https://github.com/cyborg42/rcu_128.git" }
use rcu_128::RcuCell;
fn main() {
let rcu_cell = RcuCell::new(42);
// Read the value
{
let guard = rcu_cell.read();
assert_eq!(*guard, 42);
}
// Write a new value
rcu_cell.write(100);
// Upate with a function
rcu_cell.update(|value| value + 1);
// Read the updated value
{
let guard = rcu_cell.read();
assert_eq!(*guard, 101);
}
}
This project is licensed under the MIT License. See the LICENCE file for details.