Ref

object Ref extends RefCompanion

object Ref contains factory methods that allocate an STM-managed memory location and return a Ref instance that provides access to that location.

object Ref contains factory methods that allocate an STM-managed memory location and return a Ref instance that provides access to that location.

Authors

Nathan Bronson

Companion
class
class Object
trait Matchable
class Any

Type members

Classlikes

trait View[A] extends View[A] with View[A]

Ref.View provides access to the contents of a Ref without requiring that an implicit InTxn be available. When called from within the dynamic scope of a transaction, View's methods operate as part of that transaction. When there is no transaction active View's methods are still atomic, but only for the duration of the method call.

Ref.View provides access to the contents of a Ref without requiring that an implicit InTxn be available. When called from within the dynamic scope of a transaction, View's methods operate as part of that transaction. When there is no transaction active View's methods are still atomic, but only for the duration of the method call.

A mental model of View is that view.foo(args) acts like atomic { implicit t => view.ref.foo(args) }.

Value members

Inherited methods

def apply(initialValue: Unit): Ref[Unit]
Inherited from
RefCompanion
def apply(initialValue: Double): Ref[Double]
Inherited from
RefCompanion
def apply(initialValue: Float): Ref[Float]
Inherited from
RefCompanion
def apply(initialValue: Long): Ref[Long]
Inherited from
RefCompanion
def apply(initialValue: Int): Ref[Int]
Inherited from
RefCompanion
def apply(initialValue: Char): Ref[Char]
Inherited from
RefCompanion
def apply(initialValue: Short): Ref[Short]
Inherited from
RefCompanion
def apply(initialValue: Byte): Ref[Byte]
Inherited from
RefCompanion
def apply(initialValue: Boolean): Ref[Boolean]
Inherited from
RefCompanion
def apply[A](initialValue: A): Ref[A]

Returns a Ref instance that manages a newly allocated memory location, initializing it to hold initialValue. The returned Ref is not part of any transaction's read or write set.

Returns a Ref instance that manages a newly allocated memory location, initializing it to hold initialValue. The returned Ref is not part of any transaction's read or write set.

Example:

  val x = Ref("initial") // creates a Ref[String]
  val list1 = Ref(Nil : List[String]) // creates a Ref[List[String]]
  val list2 = Ref[List[String]](Nil)  // creates a Ref[List[String]]
Inherited from
RefCompanion
inline def make[A](): Ref[A]

Returns a Ref instance that manages a newly allocated memory location holding values of type A. If you have an initial value v0 available, Ref(v0) should be preferred.

Returns a Ref instance that manages a newly allocated memory location holding values of type A. If you have an initial value v0 available, Ref(v0) should be preferred.

Inherited from
RefCompanion