Struct stim::Var[src]

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

A transaction variable.

Transaction variables may only be accessed within a transaction created by the atomically function.

Bounds

The contents of a variable must be:

A variable itself is Send but not Share. A variable can be cloned to share access to the value among tasks in a manner analagous to Arc. Notably, this means that a variable satisfies the bounds necessary to be stored in a variable itself.

Methods

impl<T: Send + Clone> Var<T>

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

Create a new transaction variable

The variable is initialized to val

fn get(&self) -> T

Read variable

Returns a clone the the contents of the variable as a transaction.

fn set(&self, val: T)

Set variable

Sets the variable to a clone of the specified value as a transaction.

Trait Implementations

impl<T: Send + Clone> Clone for Var<T>

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

Clone variable

Creates a clone of the variable which points to the same logical shared contents. Clones may be given to other tasks to participate in transactions involving the variable.

The contents of the variable are dropped when all clones are dropped.

impl<T: Send + Clone> Drop for Var<T>

fn drop(&mut self)