Expand description
A persistent memory location containing a volatile data valid during a single transaction
The underlying data is valid throughout of the course of a single
transaction scope. When the transaction is finished, the data is back to its
default value. Type T
in TCell<T>
should implement Default
and
VSafe
.
Examples
use corundum::default::*;
use std::cell::RefCell;
type P = Allocator;
#[derive(Root)]
struct Root {
v: TCell<RefCell<i32>>
}
let root = P::open::<Root>("foo.pool", O_CF).unwrap();
P::transaction(|j| {
let mut v = root.v.borrow_mut();
assert_eq!(*v, i32::default());
*v = 20; // This value is volatile and resets when transaction is complete
assert_eq!(*v, 20);
}).unwrap();
let v = root.v.borrow();
assert_eq!(*v, i32::default()); // It contains the default value outside the transaction
Implementations
Trait Implementations
sourceimpl<T: Default + VSafe + Ord + Copy, A: MemPool> Ord for TCell<T, A>
impl<T: Default + VSafe + Ord + Copy, A: MemPool> Ord for TCell<T, A>
sourceimpl<T: Default + VSafe + PartialEq + Copy, A: MemPool> PartialEq<TCell<T, A>> for TCell<T, A>
impl<T: Default + VSafe + PartialEq + Copy, A: MemPool> PartialEq<TCell<T, A>> for TCell<T, A>
sourceimpl<T: Default + VSafe + PartialOrd + Copy, A: MemPool> PartialOrd<T> for TCell<T, A>
impl<T: Default + VSafe + PartialOrd + Copy, A: MemPool> PartialOrd<T> for TCell<T, A>
sourcefn partial_cmp(&self, other: &T) -> Option<Ordering>
fn partial_cmp(&self, other: &T) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
sourcefn lt(&self, other: &T) -> bool
fn lt(&self, other: &T) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
sourcefn le(&self, other: &T) -> bool
fn le(&self, other: &T) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<T: Default + VSafe + PartialOrd + Copy, A: MemPool> PartialOrd<TCell<T, A>> for TCell<T, A>
impl<T: Default + VSafe + PartialOrd + Copy, A: MemPool> PartialOrd<TCell<T, A>> for TCell<T, A>
sourcefn partial_cmp(&self, other: &TCell<T, A>) -> Option<Ordering>
fn partial_cmp(&self, other: &TCell<T, A>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
sourcefn lt(&self, other: &TCell<T, A>) -> bool
fn lt(&self, other: &TCell<T, A>) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
sourcefn le(&self, other: &TCell<T, A>) -> bool
fn le(&self, other: &TCell<T, A>) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<T: Default + VSafe + Eq + Copy, A: MemPool> Eq for TCell<T, A>
impl<T: Default + VSafe + ?Sized, A: MemPool> PSafe for TCell<T, A>
Safe to be stored in persistent memory
impl<T, A> !Send for TCell<T, A>
Not Safe to transfer between thread boundaries
impl<T, A> !Sync for TCell<T, A>
Not Safe to be shared between threads
Auto Trait Implementations
impl<T, A> LooseTxInUnsafe for TCell<T, A> where
T: LooseTxInUnsafe,
impl<T, A> PSend for TCell<T, A> where
A: PSend,
T: PSend,
impl<T, A> RefUnwindSafe for TCell<T, A> where
T: RefUnwindSafe,
impl<T, A> TxInSafe for TCell<T, A> where
T: TxInSafe,
impl<T, A> TxOutSafe for TCell<T, A> where
A: TxOutSafe,
T: TxOutSafe,
impl<T, A> Unpin for TCell<T, A> where
A: Unpin,
T: Unpin,
impl<T, A> UnwindSafe for TCell<T, A> where
T: UnwindSafe,
impl<T, A> VSafe for TCell<T, A> where
A: VSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more