mvcc_cell

Crates.iomvcc_cell
lib.rsmvcc_cell
version0.1.2
sourcesrc
created_at2023-01-04 06:45:43.04668
updated_at2023-01-04 14:03:54.643261
descriptionSoftware-transactional memory for Rust
homepage
repositoryhttps://gitlab.com/2e71828/mvcc_cell
max_upload_size
id750661
size36,070
(e2-71828)

documentation

README

mvcc_cell is a multiversion concurrency control-based transactional-memory system for Rust.

Transactions are fully isolated and serialized with respect to controlled values:

  • Each transaction sees a fixed snapshot as of its start time
  • Any concurrent commits to cells that a transaction has accessed will prevent that transaction from committing

Example Usage

use mvcc_cell::{Mvcc,MvccCell};
let mvcc = Mvcc::new();

// Create a transactional slot
let slot = MvccCell::new(&mvcc, Box::new(0));

// Start concurrent transactions
let mut t1 = mvcc.begin();
let mut t2 = mvcc.begin();
let ro = mvcc.begin();

// Uncommitted values are not visible outside the transaction
t1[&slot] = 42;
assert_eq!(t2[&slot], 0);

// First committer wins, regardless of actual modification order
t2[&slot] = 7;
assert!(t2.try_commit().is_ok());

// Failed commits return the transaction, so you can still read
// the computed values
let t1_fail = t1.try_commit().unwrap_err();
assert_eq!(t1_fail[&slot], 42);

// Transactions always read the values that were current when
// begin() was called.
assert_eq!(ro[&slot], 0);
assert_eq!(mvcc.begin()[&slot], 7);
Commit count: 8

cargo fmt