|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.multiverse.api.TxnThreadLocal
public final class TxnThreadLocal
A ThreadLocal that contains the current Txn. The Stm and the Txn
should not rely on threadlocals, they are only used for convenience to reduce the need to carry around a
Txn.
This TxnThreadLocal has an optimization that prevents accessing the threadlocal too many times.
The Container wraps the Txn, so if a Thread gets a reference to that container and holds it, it
can modify the current transaction with a direct field access instead of another threadlocal access. It should
be used with extreme care, because the Container should not leak to another thread. It is very useful for the
TxnExecutor for example because a get/getAndSet/clear needs to be called otherwise.
| Nested Class Summary | |
|---|---|
static class |
TxnThreadLocal.Container
|
| Field Summary | |
|---|---|
static ThreadLocal<TxnThreadLocal.Container> |
threadlocal
|
| Method Summary | |
|---|---|
static void |
clearThreadLocalTxn()
Clears the threadlocal transaction. |
static Txn |
getRequiredThreadLocalTxn()
Gets the threadlocal Txn or throws a TxnMandatoryException if no transaction is found. |
static Txn |
getThreadLocalTxn()
Gets the threadlocal Txn. |
static TxnThreadLocal.Container |
getThreadLocalTxnContainer()
ThreadLocalTransaction Gets the ThreadLocal container that stores the Txn. |
static void |
setThreadLocalTxn(Txn txn)
Sets the threadlocal transaction. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final ThreadLocal<TxnThreadLocal.Container> threadlocal
| Method Detail |
|---|
public static Txn getThreadLocalTxn()
Txn. If no transaction is set, null is returned.
No checks are done on the state of the transaction (so it could be that an aborted or committed transaction is returned).
public static TxnThreadLocal.Container getThreadLocalTxnContainer()
public static Txn getRequiredThreadLocalTxn()
Txn or throws a TxnMandatoryException if no transaction is found.
No checks are done on the state of the transaction (so it could be that an aborted or committed transaction is returned).
TxnMandatoryException - if no thread local transaction is found.public static void clearThreadLocalTxn()
If a transaction is available, it isn't aborted or committed.
public static void setThreadLocalTxn(Txn txn)
If a transaction is available, it isn't aborted or committed.
txn - the new thread local transaction.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||