Modifier and Type | Method and Description |
---|---|
static void |
abort()
Aborts the Transaction in the TxnThreadLocal transaction.
|
static <E> E |
atomic(Callable<E> callable) |
static void |
atomic(Runnable runnable) |
static boolean |
atomic(TxnBooleanCallable callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.
|
static boolean |
atomic(TxnBooleanCallable either,
TxnBooleanCallable orelse)
Executes the either block, or in case of a retry, the orelse block is executed.
|
static <E> E |
atomic(TxnCallable<E> callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.
|
static <E> E |
atomic(TxnCallable<E> either,
TxnCallable<E> orelse)
Executes the either block, or in case of a retry, the orelse block is executed.
|
static double |
atomic(TxnDoubleCallable callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.
|
static double |
atomic(TxnDoubleCallable either,
TxnDoubleCallable orelse)
Executes the either block, or in case of a retry, the orelse block is executed.
|
static int |
atomic(TxnIntCallable callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.
|
static int |
atomic(TxnIntCallable either,
TxnIntCallable orelse)
Executes the either block, or in case of a retry, the orelse block is executed.
|
static long |
atomic(TxnLongCallable callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.
|
static long |
atomic(TxnLongCallable either,
TxnLongCallable orelse)
Executes the either block, or in case of a retry, the orelse block is executed.
|
static void |
atomic(TxnVoidCallable callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.
|
static void |
atomic(TxnVoidCallable either,
TxnVoidCallable orelse)
Executes the either block, or in case of a retry, the orelse block is executed.
|
static boolean |
atomicChecked(TxnBooleanCallable callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.
|
static boolean |
atomicChecked(TxnBooleanCallable either,
TxnBooleanCallable orelse)
Executes the either block, or in case of a retry, the orelse block is executed.
|
static <E> E |
atomicChecked(TxnCallable<E> callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.
|
static <E> E |
atomicChecked(TxnCallable<E> either,
TxnCallable<E> orelse)
Executes the either block, or in case of a retry, the orelse block is executed.
|
static double |
atomicChecked(TxnDoubleCallable callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.
|
static double |
atomicChecked(TxnDoubleCallable either,
TxnDoubleCallable orelse)
Executes the either block, or in case of a retry, the orelse block is executed.
|
static int |
atomicChecked(TxnIntCallable callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.
|
static int |
atomicChecked(TxnIntCallable either,
TxnIntCallable orelse)
Executes the either block, or in case of a retry, the orelse block is executed.
|
static long |
atomicChecked(TxnLongCallable callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.
|
static long |
atomicChecked(TxnLongCallable either,
TxnLongCallable orelse)
Executes the either block, or in case of a retry, the orelse block is executed.
|
static void |
atomicChecked(TxnVoidCallable callable)
Executes the callable transactionally on the GlobalStmInstance using the default TxnExecutor.
|
static void |
atomicChecked(TxnVoidCallable either,
TxnVoidCallable orelse)
Executes the either block, or in case of a retry, the orelse block is executed.
|
static void |
commit()
Commits the Transaction in the TxnThreadLocal transaction.
|
static TxnBoolean |
newTxnBoolean()
Creates a committed
TxnBoolean with false as initial value using the GlobalStmInstance . |
static TxnBoolean |
newTxnBoolean(boolean value)
Creates a committed
TxnBoolean with the provided value using the GlobalStmInstance . |
static <E> TxnDeque<E> |
newTxnDeque()
Creates a new committed unbound TxnDeque.
|
static <E> TxnDeque<E> |
newTxnDeque(int capacity)
Creates a new committed bound TxnDeque.
|
static TxnDouble |
newTxnDouble()
Creates a committed
TxnDouble with 0 as initial value using the GlobalStmInstance . |
static TxnDouble |
newTxnDouble(double value)
Creates a committed
TxnDouble with the provided value using the GlobalStmInstance . |
static <K,V> TxnMap<K,V> |
newTxnHashMap()
Creates a new committed TxnMap.
|
static <E> TxnSet<E> |
newTxnHashSet()
Creates a new committed TxnSet that is based on a 'hashtable'.
|
static TxnInteger |
newTxnInteger()
Creates a committed
TxnInteger with 0 as initial value using the GlobalStmInstance . |
static TxnInteger |
newTxnInteger(int value)
Creates a committed
TxnInteger with the provided value using the GlobalStmInstance . |
static <E> TxnList<E> |
newTxnLinkedList()
Creates a new committed TxnList based on a double linked list.
|
static TxnLong |
newTxnLong()
Creates a committed
TxnLong with 0 as initial value using the GlobalStmInstance . |
static TxnLong |
newTxnLong(long value)
Creates a committed
TxnLong with the provided value using the GlobalStmInstance . |
static <E> TxnQueue<E> |
newTxnQueue()
Creates a new committed unbound TxnQueue.
|
static <E> TxnQueue<E> |
newTxnQueue(int capacity)
Creates a new committed bound TxnQueue.
|
static <E> TxnRef<E> |
newTxnRef()
Creates a committed
TxnRef with null as initial value using the GlobalStmInstance . |
static <E> TxnRef<E> |
newTxnRef(E value)
Creates a committed
TxnRef with the provided value using the GlobalStmInstance . |
static <E> TxnStack<E> |
newTxnStack()
Creates a new committed unbound TxnStack.
|
static <E> TxnStack<E> |
newTxnStack(int capacity)
Creates a new committed bound TxnStack.
|
static void |
prepare()
Prepares the Transaction in the TxnThreadLocal transaction.
|
static void |
retry()
Does a retry.
|
static void |
scheduleCompensatingOrDeferredTask(Runnable task)
Scheduled an deferred or compensating task on the
Txn in the TxnThreadLocal. |
static void |
scheduleCompensatingTask(Runnable task)
Scheduled a compensating task on the
Txn in the TxnThreadLocal . |
static void |
scheduleDeferredTask(Runnable task)
Scheduled an deferred task on the
Txn in the TxnThreadLocal . |
public static <E> TxnList<E> newTxnLinkedList()
public static <E> TxnStack<E> newTxnStack()
public static <E> TxnStack<E> newTxnStack(int capacity)
capacity
- the maximum capacity of the stack. Integer.MAX_VALUE indicates that there is no bound.IllegalArgumentException
- if capacity smaller than 0.public static <E> TxnQueue<E> newTxnQueue()
public static <E> TxnQueue<E> newTxnQueue(int capacity)
capacity
- the maximum capacity of the queue. Integer.MAX_VALUE indicates that there is no bound.IllegalArgumentException
- if capacity smaller than 0.public static <E> TxnDeque<E> newTxnDeque()
public static <E> TxnDeque<E> newTxnDeque(int capacity)
capacity
- the maximum capacity of the deque. Integer.MAX_VALUE indicates that there is no bound.IllegalArgumentException
- if capacity is smaller than 0.public static <E> TxnSet<E> newTxnHashSet()
public static <K,V> TxnMap<K,V> newTxnHashMap()
public static void atomic(Runnable runnable)
public static <E> E atomic(Callable<E> callable)
public static <E> E atomic(TxnCallable<E> callable)
This method doesn't throw a checked exception, but if the callable does, it is wrapped inside an InvisibleCheckedException.
If you want to get most out of performance, it is best to make use of a customized TxnExecutor
instead
of relying on the default TxnExecutor that will always provide the most expensive transaction available.
callable
- The callable TxnCallable
to execute.NullPointerException
- if callable is null.InvisibleCheckedException
- if the callable throws a checked exception.public static <E> E atomicChecked(TxnCallable<E> callable) throws Exception
If you want to get most out of performance, it is best to make use of a customized TxnExecutor
instead
of relying on the default TxnExecutor that will always provide the most expensive transaction available.
callable
- The TxnCallable
to execute.NullPointerException
- if callable is null.Exception
- is the callable throws an Exceptionpublic static <E> E atomic(TxnCallable<E> either, TxnCallable<E> orelse)
either
- the either blockorelse
- the orelse block.NullPointerException
- if callable is null.InvisibleCheckedException
- if a checked exception is thrown by the callable.public static <E> E atomicChecked(TxnCallable<E> either, TxnCallable<E> orelse) throws Exception
either
- the either blockorelse
- the orelse blockNullPointerException
- if callable is null.Exception
- if the execute call fails.public static int atomic(TxnIntCallable callable)
This method doesn't throw a checked exception, but if the callable does, it is wrapped inside an InvisibleCheckedException.
If you want to get most out of performance, it is best to make use of a customized TxnExecutor
instead
of relying on the default TxnExecutor that will always provide the most expensive transaction available.
callable
- The callable TxnIntCallable
to execute.NullPointerException
- if callable is null.InvisibleCheckedException
- if the callable throws a checked exception.public static int atomicChecked(TxnIntCallable callable) throws Exception
If you want to get most out of performance, it is best to make use of a customized TxnExecutor
instead
of relying on the default TxnExecutor that will always provide the most expensive transaction available.
callable
- The TxnIntCallable
to execute.NullPointerException
- if callable is null.Exception
- is the callable throws an Exceptionpublic static int atomic(TxnIntCallable either, TxnIntCallable orelse)
either
- the either blockorelse
- the orelse block.NullPointerException
- if callable is null.InvisibleCheckedException
- if a checked exception is thrown by the callable.public static int atomicChecked(TxnIntCallable either, TxnIntCallable orelse) throws Exception
either
- the either blockorelse
- the orelse blockNullPointerException
- if callable is null.Exception
- if the execute call fails.public static long atomic(TxnLongCallable callable)
This method doesn't throw a checked exception, but if the callable does, it is wrapped inside an InvisibleCheckedException.
If you want to get most out of performance, it is best to make use of a customized TxnExecutor
instead
of relying on the default TxnExecutor that will always provide the most expensive transaction available.
callable
- The callable TxnLongCallable
to execute.NullPointerException
- if callable is null.InvisibleCheckedException
- if the callable throws a checked exception.public static long atomicChecked(TxnLongCallable callable) throws Exception
If you want to get most out of performance, it is best to make use of a customized TxnExecutor
instead
of relying on the default TxnExecutor that will always provide the most expensive transaction available.
callable
- The TxnLongCallable
to execute.NullPointerException
- if callable is null.Exception
- is the callable throws an Exceptionpublic static long atomic(TxnLongCallable either, TxnLongCallable orelse)
either
- the either blockorelse
- the orelse block.NullPointerException
- if callable is null.InvisibleCheckedException
- if a checked exception is thrown by the callable.public static long atomicChecked(TxnLongCallable either, TxnLongCallable orelse) throws Exception
either
- the either blockorelse
- the orelse blockNullPointerException
- if callable is null.Exception
- if the execute call fails.public static double atomic(TxnDoubleCallable callable)
This method doesn't throw a checked exception, but if the callable does, it is wrapped inside an InvisibleCheckedException.
If you want to get most out of performance, it is best to make use of a customized TxnExecutor
instead
of relying on the default TxnExecutor that will always provide the most expensive transaction available.
callable
- The callable TxnDoubleCallable
to execute.NullPointerException
- if callable is null.InvisibleCheckedException
- if the callable throws a checked exception.public static double atomicChecked(TxnDoubleCallable callable) throws Exception
If you want to get most out of performance, it is best to make use of a customized TxnExecutor
instead
of relying on the default TxnExecutor that will always provide the most expensive transaction available.
callable
- The TxnDoubleCallable
to execute.NullPointerException
- if callable is null.Exception
- is the callable throws an Exceptionpublic static double atomic(TxnDoubleCallable either, TxnDoubleCallable orelse)
either
- the either blockorelse
- the orelse block.NullPointerException
- if callable is null.InvisibleCheckedException
- if a checked exception is thrown by the callable.public static double atomicChecked(TxnDoubleCallable either, TxnDoubleCallable orelse) throws Exception
either
- the either blockorelse
- the orelse blockNullPointerException
- if callable is null.Exception
- if the execute call fails.public static boolean atomic(TxnBooleanCallable callable)
This method doesn't throw a checked exception, but if the callable does, it is wrapped inside an InvisibleCheckedException.
If you want to get most out of performance, it is best to make use of a customized TxnExecutor
instead
of relying on the default TxnExecutor that will always provide the most expensive transaction available.
callable
- The callable TxnBooleanCallable
to execute.NullPointerException
- if callable is null.InvisibleCheckedException
- if the callable throws a checked exception.public static boolean atomicChecked(TxnBooleanCallable callable) throws Exception
If you want to get most out of performance, it is best to make use of a customized TxnExecutor
instead
of relying on the default TxnExecutor that will always provide the most expensive transaction available.
callable
- The TxnBooleanCallable
to execute.NullPointerException
- if callable is null.Exception
- is the callable throws an Exceptionpublic static boolean atomic(TxnBooleanCallable either, TxnBooleanCallable orelse)
either
- the either blockorelse
- the orelse block.NullPointerException
- if callable is null.InvisibleCheckedException
- if a checked exception is thrown by the callable.public static boolean atomicChecked(TxnBooleanCallable either, TxnBooleanCallable orelse) throws Exception
either
- the either blockorelse
- the orelse blockNullPointerException
- if callable is null.Exception
- if the execute call fails.public static void atomic(TxnVoidCallable callable)
This method doesn't throw a checked exception, but if the callable does, it is wrapped inside an InvisibleCheckedException.
If you want to get most out of performance, it is best to make use of a customized TxnExecutor
instead
of relying on the default TxnExecutor that will always provide the most expensive transaction available.
callable
- The callable TxnVoidCallable
to execute.NullPointerException
- if callable is null.InvisibleCheckedException
- if the callable throws a checked exception.public static void atomicChecked(TxnVoidCallable callable) throws Exception
If you want to get most out of performance, it is best to make use of a customized TxnExecutor
instead
of relying on the default TxnExecutor that will always provide the most expensive transaction available.
callable
- The TxnVoidCallable
to execute.NullPointerException
- if callable is null.Exception
- is the callable throws an Exceptionpublic static void atomic(TxnVoidCallable either, TxnVoidCallable orelse)
either
- the either blockorelse
- the orelse block.NullPointerException
- if callable is null.InvisibleCheckedException
- if a checked exception is thrown by the callable.public static void atomicChecked(TxnVoidCallable either, TxnVoidCallable orelse) throws Exception
either
- the either blockorelse
- the orelse blockNullPointerException
- if callable is null.Exception
- if the execute call fails.public static TxnInteger newTxnInteger(int value)
TxnInteger
with the provided value using the GlobalStmInstance
.value
- the initial value of the TnxIntegerpublic static TxnInteger newTxnInteger()
TxnInteger
with 0 as initial value using the GlobalStmInstance
.public static TxnLong newTxnLong()
TxnLong
with 0 as initial value using the GlobalStmInstance
.public static TxnLong newTxnLong(long value)
TxnLong
with the provided value using the GlobalStmInstance
.value
- the initial value of the TxnLong.public static TxnDouble newTxnDouble()
TxnDouble
with 0 as initial value using the GlobalStmInstance
.public static TxnDouble newTxnDouble(double value)
TxnDouble
with the provided value using the GlobalStmInstance
.value
- the initial value.public static TxnBoolean newTxnBoolean()
TxnBoolean
with false as initial value using the GlobalStmInstance
.public static TxnBoolean newTxnBoolean(boolean value)
TxnBoolean
with the provided value using the GlobalStmInstance
.value
- the initial valuepublic static <E> TxnRef<E> newTxnRef()
TxnRef
with null as initial value using the GlobalStmInstance
.E
- the type of the TxnRef.public static <E> TxnRef<E> newTxnRef(E value)
TxnRef
with the provided value using the GlobalStmInstance
.E
- the type of the TxnRef.value
- the initial value of the TxnRef.public static void retry()
Under the hood the retry throws an Retry that will be caught up the callstack
(by the TxnExecutor
for example). The Retry should not be caught by user code in almost all cases.
public static void prepare()
For more information see Txn.prepare()
.
TxnMandatoryException
- if no active transaction is found.IllegalTransactionStateException
- if the active transaction is not in the correct
state for this operation.ControlFlowError
public static void abort()
For more information see Txn.abort()
.
TxnMandatoryException
- if no active transaction is found.IllegalTransactionStateException
- if the active transaction is not in the correct
state for this operation.ControlFlowError
public static void commit()
For more information see Txn.commit()
.
TxnMandatoryException
- if no active transaction is found.IllegalTransactionStateException
- if the active transaction is not in the correct
state for this operation.ControlFlowError
public static void scheduleCompensatingOrDeferredTask(Runnable task)
Txn
in the TxnThreadLocal. This task is
executed after the transaction commits or aborts.task
- the deferred task to execute.NullPointerException
- if task is null.TxnMandatoryException
- if no transaction is set on the TxnThreadLocal
.IllegalTxnStateException
- if the transaction is not in the correct state to accept a compensating or deferred task.public static void scheduleDeferredTask(Runnable task)
Txn
in the TxnThreadLocal
. This task is executed after
the transaction commits and one of the use cases is starting transactions.task
- the deferred task to execute.NullPointerException
- if task is null.TxnMandatoryException
- if no transaction is set on the TxnThreadLocal
.IllegalTxnStateException
- if the transaction is not in the correct state to accept a deferred task.public static void scheduleCompensatingTask(Runnable task)
Txn
in the TxnThreadLocal
. This task is executed after
the transaction aborts and one of the use cases is cleaning up non transaction resources like the file system.task
- the deferred task to execute.NullPointerException
- if task is null.TxnMandatoryException
- if no transaction is set on the TxnThreadLocal
.IllegalTxnStateException
- if the transaction is not in the correct state to accept a compensating task.Copyright © 2020. All rights reserved.