pub struct TVar<T> { /* private fields */ }
Expand description
TVar
is our handle to a variable, but reading and writing go through a transaction.
It also tracks which threads are waiting on it.
Implementations
sourceimpl<T: Any + Sync + Send + Clone> TVar<T>
impl<T: Any + Sync + Send + Clone> TVar<T>
sourcepub fn new(value: T) -> TVar<T>
pub fn new(value: T) -> TVar<T>
Create a new TVar
. The initial version is 0, so that if a
TVar
is created in the middle of a transaction it will
not cause any MVCC conflict during the commit.
sourcepub fn read_clone(&self) -> StmResult<T>
pub fn read_clone(&self) -> StmResult<T>
Read the value of the TVar
as a clone, for subsequent modification. Only call this inside atomically
.
sourcepub fn read(&self) -> StmResult<Arc<T>>
pub fn read(&self) -> StmResult<Arc<T>>
Read the value of the TVar
. Only call this inside atomically
.
sourcepub fn write(&self, value: T) -> StmResult<()>
pub fn write(&self, value: T) -> StmResult<()>
Replace the value of the TVar
. Only call this inside atomically
.
sourcepub fn update<F>(&self, f: F) -> StmResult<()> where
F: FnOnce(T) -> T,
pub fn update<F>(&self, f: F) -> StmResult<()> where
F: FnOnce(T) -> T,
Apply an update on the value of the TVar
. Only call this inside atomically
.
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for TVar<T>
impl<T> Send for TVar<T> where
T: Send,
impl<T> Sync for TVar<T> where
T: Sync,
impl<T> Unpin for TVar<T> where
T: Unpin,
impl<T> !UnwindSafe for TVar<T>
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more