rcu_cell

Crates.iorcu_cell
lib.rsrcu_cell
version1.2.1
created_at2018-09-26 08:36:14.652723+00
updated_at2025-05-09 08:18:27.646243+00
descriptiona lockless rcu cell implementation
homepagehttps://github.com/Xudong-Huang/rcu_cell
repositoryhttps://github.com/Xudong-Huang/rcu_cell
max_upload_size
id86591
size34,957
Xudong Huang (Xudong-Huang)

documentation

https://docs.rs/rcu_cell

README

Build Status Current Crates.io Version Document

RcuCell

A lockless rcu cell implementation that can be used safely in multithread context.

Features

  • Support multi-thread read and write operations.

  • The read operation would not block other read operations.

  • The read operation is always waitless.

  • The read operation is something like Arc::clone.

  • The write operation would not block other read operations.

  • The write operation is lockless.

  • The write operation is something like Atomic Swap.

  • The RcuCell could contain no data

  • Could be compiled with no_std

Usage

    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);
Commit count: 141

cargo fmt