Struct stm::Var [] [src]

pub struct Var<T> {
    // some fields omitted
}

A variable that can be used in a STM-Block

Methods

impl<T> Var<T> where T: Any + Sync + Send + Clone
[src]

fn new(val: T) -> Var<T>

create a new var

fn read_atomic(&self) -> T

read a value atomically

this should be called from outside of stm and is faster than wrapping a read in STM but is not composable

read_atomic returns a clone of the value.

If the value contains a shared reference mutating it is a side effect which may break STM-semantics

This is a faster alternative to

stm!(var.read_atomic())
    .atomically();

fn read_ref_atomic(&self) -> Arc<Any + Send + Sync>

read a value atomically but return a reference

this is mostly used internally but can be useful in certain cases where the additional clone performed by read_atomic is not wanted

fn read(&self) -> T

the normal way to access a var

it is used to read a var from inside of a STM-Block

Panics

Panics when called from outside of a STM-Block

fn write(&self, value: T)

the normal way to write a var

it is used to write a var from inside of a STM-Block and does not immediately write but wait for commit

Panics

Panics when called from outside of a STM-Block

fn wake_all(&self)

wake all threads that are waiting for this value

this is mostly used internally

fn control_block(&self) -> &Arc<VarControlBlock>

access the control block of the var

internal use only

Trait Implementations

impl<T: Clone> Clone for Var<T>
[src]

fn clone(&self) -> Var<T>

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more