object TxnLocal
- Alphabetic
- By Inheritance
- TxnLocal
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
apply[A](init: ⇒ A = null.asInstanceOf[A], initialValue: (InTxn) ⇒ A = null, beforeCommit: (InTxn) ⇒ Unit = null, whilePreparing: (InTxnEnd) ⇒ Unit = null, whileCommitting: (InTxnEnd) ⇒ Unit = null, afterCommit: (A) ⇒ Unit = null, afterRollback: (Status) ⇒ Unit = null, afterCompletion: (Status) ⇒ Unit = null): TxnLocal[A]
Returns a new transaction-local that holds values of type
A.Returns a new transaction-local that holds values of type
A. OneTxnLocalinstance holds a separate value for each transaction in which it has been accessed. The value associated with a particular atomic block is created on demand, and discarded at the same time that the atomic block's after-completion handlers are invoked.TxnLocalhas a similar relationship to transactions asThreadLocalhas to threads.There are two ways to specify the initial value that will be used if the first access inside a transaction is not a
set. If noInTxncontext is needed to compute the initial value then the by-name parameterinitis the most convenient. Because this is the first parameter, you can omit the parameter name. To construct aTxnLocalwith a default value ofaValue, simplyval tl = TxnLocal(aValue)If computing the initial value requires access to
Refs, then it is better to use theinitialValueparameter, which lets you writeval tl = TxnLocal(initialValue = { implicit txn => // Ref reads or writes, or handler registration })
Unlike
Refs,TxnLocals can be read or written from inside while-preparing or while-committing callbacks, with two conditions: if the first access is from one of these callbacks then nobeforeCommitparameter can be present; and if the first access is from one of these callbacks and it is not a write then you must use theinitinitialization method.This factory method also accepts parameters that correspond to
Txn's transaction life-cycle handlers. These handlers will be registered in any transaction that reads or writes the returnedTxnLocal. They are roughlybeforeCommit- the last time thatRefs can be read or written;whilePreparing- the last time that the transaction can be rolled back;whileCommitting- actions that should be atomic with respect to the transaction (keep them fast to avoid scalability issues);afterCommit- called at some time after commit;afterRollback- called at some time after rollback of the nesting level in which theTxnLocalwas first accessed; andafterCompletion- called either after commit or after rollback.
The value stored in a
TxnLocalis subject to partial rollback: initial value computations and writes from a nested atomic block will be discarded if the block is rolled back. -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )