29 releases (12 stable)

1.2.0 Dec 27, 2024
1.1.0 Nov 13, 2024
0.2.3 Nov 8, 2024
0.1.11 Mar 9, 2023
0.1.3 Oct 29, 2018

⚠️ Issues reported

#108 in Concurrency

Download history 12/week @ 2024-10-01 4/week @ 2024-10-08 3/week @ 2024-10-15 887/week @ 2024-11-05 290/week @ 2024-11-12 55/week @ 2024-11-19 7/week @ 2024-11-26 620/week @ 2024-12-03 190/week @ 2024-12-10 189/week @ 2024-12-17 167/week @ 2024-12-24 24/week @ 2024-12-31 14/week @ 2025-01-07 1/week @ 2025-01-14

207 downloads per month
Used in 10 crates (3 directly)

LGPL-3.0

21KB
493 lines

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);

Dependencies

~110KB