Member

trait Member

A participant in a synchronized group commit. Each member of a commit barrier must arrange for either atomic or cancel to be called, otherwise the other members won't be able to commit.

A participant in a synchronized group commit. Each member of a commit barrier must arrange for either atomic or cancel to be called, otherwise the other members won't be able to commit.

class Object
trait Matchable
class Any

Value members

Abstract methods

def atomic[Z](body: InTxn => Z): Either[CancelCause, Z]

Atomically executes body as part of a commit barrier, ensuring that if the transaction commits, all actions performed by all members of the commit barrier appear to occur simultaneously. If the transaction commits then the value v returned by body is returned as Right(v). If this member is cancelled then this method returns Left(c), where c describes the first cause passed to the cancel method. If this member is not cancelled but the transaction is rolled back without the possibility of retry, then this method throws an exception the same as any other atomic block (see TxnExecutor.apply).

Atomically executes body as part of a commit barrier, ensuring that if the transaction commits, all actions performed by all members of the commit barrier appear to occur simultaneously. If the transaction commits then the value v returned by body is returned as Right(v). If this member is cancelled then this method returns Left(c), where c describes the first cause passed to the cancel method. If this member is not cancelled but the transaction is rolled back without the possibility of retry, then this method throws an exception the same as any other atomic block (see TxnExecutor.apply).

It is not allowed to chain orAtomic onto this form of atomic, but you can accomplish the same effect with a nested atomic block:

  member.atomic { implicit txn =>
    atomic { implicit txn =>
      ... first alternative
    } orAtomic { implicit txn =>
      ... second alternative
    }
  }

In the current version of ScalaSTM this method may only be used if there is no enclosing transaction; an STM implementation may throw IllegalStateException if there is already an active transaction on this thread. This restriction might be relaxed in the future if there is a use case for it (and a semantics for how it should work).

Value Params
body

the code to run atomically

Returns

Right(v) where v is the result of successfully running body in an atomic block, or Left(c) where c is the reason for this member's cancellation

Throws
IllegalStateException

if called from inside the dynamic scope of an existing transaction and that is not supported by the chosen STM implementation

def cancel(cause: UserCancel): Unit

Removes this member from the commit barrier, and causes any pending or future calls to this.atomic to return a Left. If the commit barrier has already committed successfully this method throws IllegalStateException. It is safe to call this method multiple times.

Removes this member from the commit barrier, and causes any pending or future calls to this.atomic to return a Left. If the commit barrier has already committed successfully this method throws IllegalStateException. It is safe to call this method multiple times.

Value Params
cause

the cancel cause to return from atomic

Throws
IllegalStateException

if the commit barrier has already decided to commit

Returns the commit barrier of which this instance is a member.

Returns the commit barrier of which this instance is a member.

Returns the TxnExecutor that will be used by atomic. This is initialized during construction to the default TxnExecutor (returned by scala.concurrent.stm.atomic).

Returns the TxnExecutor that will be used by atomic. This is initialized during construction to the default TxnExecutor (returned by scala.concurrent.stm.atomic).

def executor_=(v: TxnExecutor): Unit

Changes the TxnExecutor that will be used by atomic.

Changes the TxnExecutor that will be used by atomic.