Crates.io | rcu_cell |
lib.rs | rcu_cell |
version | |
source | src |
created_at | 2018-09-26 08:36:14.652723 |
updated_at | 2024-11-09 08:32:11.241656 |
description | a lockless rcu cell implementation |
homepage | https://github.com/Xudong-Huang/rcu_cell |
repository | https://github.com/Xudong-Huang/rcu_cell |
max_upload_size | |
id | 86591 |
Cargo.toml error: | TOML parse error at line 22, column 1 | 22 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A lockless rcu cell implementation that can be used safely in multithread context.
Support multi-thread read and write operations.
The read operation would not block other read operation.
The read operation is something like Arc::clone
The write operation is something like Atomic Swap.
The write operation would block all read operations.
The RcuCell could contain no data
Could be compiled with no_std
use rcu_cell::RcuCell;
use std::sync::Arc;
let t = Arc::new(RcuCell::new(10));
let t1 = t.clone();
let t2 = t.clone();
let d1 = t1.take().unwrap();
assert_eq!(*d1, 10);
assert_eq!(t1.read(), None);
let d2 = t2.write(42);
assert!(d2.is_none());
let d3 = t2.read().unwrap();
assert_eq!(*d3, 42);