STM

object STM

Java-friendly API for ScalaSTM. These methods can also be statically imported.

Java-friendly API for ScalaSTM. These methods can also be statically imported.

class Object
trait Matchable
class Any

Type members

Classlikes

abstract class Transformer[A <: AnyRef]

Value members

Concrete methods

def afterCommit(task: Runnable): Unit

Add a task to run after the current transaction has committed.

Add a task to run after the current transaction has committed.

Value Params
task

the Runnable task to run after transaction commit

Throws
IllegalStateException

if called from outside a transaction

def afterCompletion(task: Runnable): Unit

Add a task to run after the current transaction has either rolled back or committed.

Add a task to run after the current transaction has either rolled back or committed.

Value Params
task

the Runnable task to run after transaction completion

Throws
IllegalStateException

if called from outside a transaction

def afterRollback(task: Runnable): Unit

Add a task to run after the current transaction has rolled back.

Add a task to run after the current transaction has rolled back.

Value Params
task

the Runnable task to run after transaction rollback

Throws
IllegalStateException

if called from outside a transaction

def atomic(runnable: Runnable): Unit

Atomic block that takes a Runnable.

Atomic block that takes a Runnable.

Value Params
runnable

the Runnable to run within a transaction

def atomic[A <: AnyRef](callable: Callable[A]): A

Atomic block that takes a Callable.

Atomic block that takes a Callable.

Value Params
callable

the Callable to run within a transaction

Returns

the value returned by the Callable

def getAndTransform[A <: AnyRef](ref: View[A], f: Transformer[A]): A

Transform the value stored by ref by applying the function f and return the old value.

Transform the value stored by ref by applying the function f and return the old value.

Value Params
f

the function to be applied

ref

the Ref.View to be transformed

Returns

the old value of ref

def increment(ref: View[Integer], delta: Int): Unit

Increment the java.lang.Integer value of a Ref.View.

Increment the java.lang.Integer value of a Ref.View.

Value Params
delta

the amount to increment

ref

the Ref.View<Integer> to be incremented

def increment(ref: View[Long], delta: Long): Unit

Increment the java.lang.Long value of a Ref.View.

Increment the java.lang.Long value of a Ref.View.

Value Params
delta

the amount to increment

ref

the Ref.View<Long> to be incremented

def newArrayAsList[A <: AnyRef](length: Int): List[A]

Create an empty TArray. Return a java.util.List view of this Array.

Create an empty TArray. Return a java.util.List view of this Array.

Value Params
length

the length of the TArray.View to be created

Returns

a new, empty TArray.View wrapped as a java.util.List.

def newMap[A, B](): Map[A, B]

Create an empty TMap. Return a java.util.Map view of this TMap.

Create an empty TMap. Return a java.util.Map view of this TMap.

Returns

a new, empty TMap.View wrapped as a java.util.Map.

def newRef[A](initialValue: A): View[A]

Create a Ref with an initial value. Return a Ref.View, which does not require implicit transactions.

Create a Ref with an initial value. Return a Ref.View, which does not require implicit transactions.

Value Params
initialValue

the initial value for the newly created Ref.View

Returns

a new Ref.View

def newSet[A](): Set[A]

Create an empty TSet. Return a java.util.Set view of this TSet.

Create an empty TSet. Return a java.util.Set view of this TSet.

Returns

a new, empty TSet.View wrapped as a java.util.Set.

def newTArray[A <: AnyRef](length: Int): View[A]

Create a TArray containing length elements. Return a TArray.View, which does not require implicit transactions. See newList for included java conversion.

Create a TArray containing length elements. Return a TArray.View, which does not require implicit transactions. See newList for included java conversion.

Value Params
length

the length of the TArray.View to be created

Returns

a new TArray.View containing length elements (initially null)

def newTMap[A, B](): View[A, B]

Create an empty TMap. Return a TMap.View, which does not require implicit transactions. See newMap for included java conversion.

Create an empty TMap. Return a TMap.View, which does not require implicit transactions. See newMap for included java conversion.

Returns

a new, empty TMap.View

def newTSet[A](): View[A]

Create an empty TSet. Return a TSet.View, which does not require implicit transactions. See newSet for included java conversion.

Create an empty TSet. Return a TSet.View, which does not require implicit transactions. See newSet for included java conversion.

Returns

a new, empty TSet.View

def retry(): Unit

Causes the enclosing transaction to back up and wait until one of the Refs touched by this transaction has changed.

Causes the enclosing transaction to back up and wait until one of the Refs touched by this transaction has changed.

Throws
IllegalStateException

if not in a transaction

def retryFor(timeoutMillis: Long): Unit

Like retry, but limits the total amount of blocking. This method only returns normally when the timeout has expired.

Like retry, but limits the total amount of blocking. This method only returns normally when the timeout has expired.

def transform[A <: AnyRef](ref: View[A], f: Transformer[A]): Unit

Transform the value stored by ref by applying the function f.

Transform the value stored by ref by applying the function f.

Value Params
f

the function to be applied

ref

the Ref.View to be transformed

def transformAndGet[A <: AnyRef](ref: View[A], f: Transformer[A]): A

Transform the value stored by ref by applying the function f and return the new value.

Transform the value stored by ref by applying the function f and return the new value.

Value Params
f

the function to be applied

ref

the Ref.View to be transformed

Returns

the new value of ref