persistent_stack 0.1.1

Concurrent persistent stack
Documentation
  • Coverage
  • 60%
    6 out of 10 items documented5 out of 7 items with examples
  • Size
  • Source code size: 7.79 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.66 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • timcryt/persistent_stack
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • timcryt

Concurrent persistent stack

Fast, concurrent and easy to use implementation of persistent stack.

Operations cost

  • push - O(1)
  • pop - O(1)
  • clone - O(1)
  • iter next - O(1)

Example

use persistent_stack::PersistentStack;

let mut s1 = PersistentStack::new();
s1.push(1);

let mut s2 = s1.clone(); // O(1) operation

std::thread::spawn(move || {
    s2.push(2); // PersistentStack values can be shared safely
    assert_eq!(s2.iter().copied().collect::<Vec<_>>(), vec![2, 1]);

    std::thread::sleep(std::time::Duration::from_millis(20));

    s2.push(4);
    assert_eq!(s2.iter().copied().collect::<Vec<_>>(), vec![4, 2, 1]);

    assert_eq!(s2.pop(), Ok(4)); // We can also pop values from stack
});

s1.push(3);
assert_eq!(s1.iter().copied().collect::<Vec<_>>(), vec![3, 1]);

std::thread::sleep(std::time::Duration::from_millis(20));

s1.push(5);
assert_eq!(s1.iter().copied().collect::<Vec<_>>(), vec![5, 3, 1]);