[−][src]Module swym::tptr
A transactional memory primitive powering recursive data structures.
Motivation
Let's see what happens when we try to build a simple transactional box using only TCell
.
ⓘThis example deliberately fails to compile
use swym::{rw, tcell::TCell}; let x = TCell::new(Box::new(TCell::new(42))); rw!(|tx| { let box_ref = x.borrow(tx, Default::default())?; // error borrowed value does not live long enough let fourty_two = box_ref.get(tx, Default::default())?; Ok(()) });
The problem is that data borrowed from any TCell
(in the above example to outermost TCell
)
may not come from shared memory, but instead the write set - which is speculative. Values in the
write set change throughout the course of a transaction, and may be overwritten.
TPtr
is the current experimental workaround akin to a raw pointer, but capable of publishing
and privatizing Box's.
EXPERIMENTAL
TPtr
type may have safety issues, or other flaws. The API is subject to change.
Structs
Publisher | |
TPtr | Experimental building block for recursive data structures. |