Interface TxnObject
-
- All Known Subinterfaces:
TxnBoolean,TxnDouble,TxnInteger,TxnLong,TxnRef<E>
- All Known Implementing Classes:
GammaTxnBoolean,GammaTxnDouble,GammaTxnInteger,GammaTxnLong,GammaTxnRef
public interface TxnObject
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringatomicToString()Returns a String representation of the object using the provided transaction without looking at aTxnThreadLocal.voidensure()Does an ensure.voidensure(Txn self)Does an ensure.LockgetLock()Gets theLockthat belongs to this TxnObject.StmgetStm()Returns theStmthis TxnObject is part of.longgetVersion()Returns the current version of the transactional object.StringtoDebugString()Returns a debug representation of the TxnObject.StringtoString()Returns a String representation of the Object using theTxnon theTxnThreadLocal.StringtoString(Txn txn)Returns a String representation of the object using the providedTxn.
-
-
-
Method Detail
-
getStm
Stm getStm()
Returns theStmthis TxnObject is part of. Once a TxnObject is created using some Stm, it will never become part of another Stm.- Returns:
- the Stm this TxnObject is part of. Returned value will never be null.
-
getLock
Lock getLock()
Gets theLockthat belongs to this TxnObject. This call doesn't cause any locking, it only provides access to the object that is able to lock. The returned value will never be null.This call also doesn't rely on a
Txn.- Returns:
- the Lock
- Throws:
UnsupportedOperationException- if this operation is not supported.
-
getVersion
long getVersion()
Returns the current version of the transactional object. Each time an update happens, the value is increased. It depends on the stm implementation if the version over references has any meaning. With the MVCC there is a relation, but with the SkySTM isn't.This method doesn't look at the
TxnThreadLocal.- Returns:
- the current version.
-
ensure
void ensure()
Does an ensure. What is means is that at the end of the transaction (so deferred), the transaction checks if no other transaction has made an update, if this TxnObject only is read. The ensure is a way to prevent to writeskew problem on the ref level (seeIsolationLevelfor more detail about the writeskew problem}This can safely be called on an TxnObject that already is locked, although it doesn't provide much value since with a locked TxnObject, since the writeskew problem can't occur anymore because it can't be changed.
Unlike the
Lock.acquire(LockMode)which is pessimistic, ensure is optimistic. This means that a conflict can be detected once the transaction commits.This method has no effect if the
Txnis readonly, because a writeskew is not possible with a readonly transaction.This call lifts on the
Txnstored in theTxnThreadLocal.- Throws:
TxnExecutionExceptionControlFlowError- See Also:
ensure(Txn)
-
ensure
void ensure(Txn self)
Does an ensure. What is means is that at the end of the transaction (so deferred), the transaction checks if no other transaction has made an update, if this TxnObject only is read. The ensure is a way to prevent to writeskew problem on the ref level (seeIsolationLevelfor more detail about the writeskew problem}This can safely be called on an TxnObject that already is locked, although it doesn't provide much value since with a locked TxnObject, since the writeskew problem can't occur anymore because it can't be changed.
Unlike the
Lock.acquire(LockMode)which is pessimistic, ensure is optimistic. This means that a conflict can be detected once the transaction commits.This method has no effect if the
Txnis readonly, because a writeskew is not possible with a readonly transaction.- Parameters:
self- the Txn this call lifts on.- Throws:
NullPointerException- if self is null.TxnExecutionExceptionControlFlowError- See Also:
ensure()
-
toDebugString
String toDebugString()
Returns a debug representation of the TxnObject. The data used doesn't have to be consistent, it is a best effort. This method doesn't rely on a running transaction.- Returns:
- the debug representation of the TxnObject.
-
toString
String toString()
Returns a String representation of the Object using theTxnon theTxnThreadLocal.- Overrides:
toStringin classObject- Returns:
- the toString representation
- Throws:
TxnExecutionExceptionControlFlowError
-
toString
String toString(Txn txn)
Returns a String representation of the object using the providedTxn.- Parameters:
txn- the Txn used.- Returns:
- the String representation of the object.
- Throws:
NullPointerException- if tx is null.ControlFlowError
-
atomicToString
String atomicToString()
Returns a String representation of the object using the provided transaction without looking at aTxnThreadLocal. The outputted value doesn't need to be consistent from some point in time, only a best effort is made.- Returns:
- the String representation.
-
-