pub trait Read<T> where
    T: Clone
{ fn get<'a>(&'a self, var: &'a RLUVar<T>) -> Result<ReadGuard<'a, T>>; }
Expand description

Read<T> provides immutable read access to the synchronized data via the current managing context.

Required Methods

Returns an immutable ReadGuard on the value of RLUVar

This function effectively returns either the original value, if it has not been modified, or an immutable reference to the underlying write log, if the log has not been commited to memory yet. The ReadGuard ensures that after dereferencing and reading the value, all outstanding commits to the internal value will be conducted.

Example
use stronghold_rlu::*;

// create simple value, that should be managed by RLU
let value = 6usize;

// first we need to create a controller
let ctrl = RLU::new();

// via the controller  we create a RLUVar reference
let rlu_var: RLUVar<usize> = ctrl.create(value);

// we clone the reference to it to use it inside a thread
let var_1 = rlu_var.clone();

// via the controller we can spawn a thread safe context
ctrl.execute(move |context| {
    let inner = context.get(&var_1)?;
    assert_eq!(*inner, 6);
    Ok(())
});

Implementors