Nested transaction are not supported but calling inside an existing transaction, which must be compatible, (i.e. a write needs a WRITE transaction). causes the existing transaction to be used.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Transactional,
X>
XExecute and return a value in a transaction with the giventransaction type
.static <T extends Transactional,
X>
XExecute in a "read" transaction that can promote to "write" and return some calculated value.static <T extends Transactional,
X>
XcalculateRead
(T txn, Supplier<X> r) Execute and return a value in a read transactionstatic <T extends Transactional,
X>
XcalculateWrite
(T txn, Supplier<X> r) Execute and return a value in a write transaction.static <T extends Transactional>
voidExecute application code in a transaction with the giventransaction type
.static <T extends Transactional>
voidExecute in a "read" transaction that can promote to "write".static <T extends Transactional>
voidexecuteRead
(T txn, Runnable r) Execute in a read transactionstatic <T extends Transactional>
voidexecuteWrite
(T txn, Runnable r) Execute the Runnable in a write transaction
-
Constructor Details
-
Txn
public Txn()
-
-
Method Details
-
execute
Execute in a "read" transaction that can promote to "write".Such a transaction may abort if an update is executed by another thread before this one is promoted to "write" mode. If so, the data protected by
txn
is unchanged.If the application knows updates will be needed, consider using
executeWrite(T, java.lang.Runnable)
which starts in "write" mode.The application code can call
Transactional.promote()
to attempt to change from "read" to "write"; thepromote
method returns a boolean indicating whether the promotion was possible or not. -
calculate
Execute in a "read" transaction that can promote to "write" and return some calculated value.Such a transaction may abort if an update is executed by another thread before this one is promoted to "write" mode. If so, the data protected by
txn
is unchanged.If the application knows updates will be needed, consider using
executeWrite(T, java.lang.Runnable)
which starts in "write" mode.The application code can call
Transactional.promote()
to attempt to change from "read" to "write"; thepromote
method returns a boolean indicating whether the promotion was possible or not. -
exec
Execute application code in a transaction with the giventransaction type
. -
calc
Execute and return a value in a transaction with the giventransaction type
. -
executeRead
Execute in a read transaction -
calculateRead
Execute and return a value in a read transaction -
executeWrite
Execute the Runnable in a write transaction -
calculateWrite
Execute and return a value in a write transaction.
-