scala.concurrent.stm.CommitBarrier
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.
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).
the code to run atomically
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
if called from inside the dynamic scope of an existing transaction and that is not supported by the chosen STM implementation
Removes this member from the commit barrier, and causes any pending
or future calls to this.atomic
to return a Left
.
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.
the cancel cause to return from atomic
if the commit barrier has already decided to commit
Returns the commit barrier of which this instance is a member.
Returns the TxnExecutor
that will be used by 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
).
Changes the TxnExecutor
that will be used by atomic
.
A participant in a synchronized group commit. Each member of a commit barrier must arrange for either
atomic
orcancel
to be called, otherwise the other members won't be able to commit.