Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Xudong-Huang/rcu_cell
rust rcu cell library
https://github.com/Xudong-Huang/rcu_cell
Last synced: 2 months ago
JSON representation
rust rcu cell library
- Host: GitHub
- URL: https://github.com/Xudong-Huang/rcu_cell
- Owner: Xudong-Huang
- License: lgpl-3.0
- Created: 2017-10-24T02:18:24.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-11-07T09:29:21.000Z (2 months ago)
- Last Synced: 2024-11-07T19:12:33.073Z (2 months ago)
- Language: Rust
- Size: 35.2 KB
- Stars: 19
- Watchers: 5
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://github.com/Xudong-Huang/rcu_cell/workflows/CI/badge.svg)](https://github.com/Xudong-Huang/rcu_cell/actions?query=workflow%3ACI+branch%3Amaster)
[![Current Crates.io Version](https://img.shields.io/crates/v/rcu_cell.svg)](https://crates.io/crates/rcu_cell)
[![Document](https://img.shields.io/badge/doc-rcu_cell-green.svg)](https://docs.rs/rcu_cell)# 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 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## Usage
```rust
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);
```