Class GammaTxnRef<E>
- Type Parameters:
E-
- All Implemented Interfaces:
Lock,TxnRef<E>,TxnObject,MultiverseConstants,GammaConstants,GammaObject
-
Field Summary
Fields inherited from class org.multiverse.stms.gamma.transactionalobjects.BaseGammaTxnRef
long_value, ref_value, typeFields inherited from class org.multiverse.stms.gamma.transactionalobjects.AbstractGammaObject
___unsafe, identityHashCode, listeners, listenersOffset, MASK_OREC_EXCLUSIVELOCK, MASK_OREC_READBIASED, MASK_OREC_READLOCKS, MASK_OREC_READONLY_COUNT, MASK_OREC_SURPLUS, MASK_OREC_UPDATELOCK, orec, stm, valueOffset, versionFields inherited from interface org.multiverse.stms.gamma.GammaConstants
FAILURE, MASK_CONFLICT, MASK_SUCCESS, MASK_UNREGISTERED, REGISTRATION_DONE, REGISTRATION_NONE, REGISTRATION_NOT_NEEDED, TRANLOCAL_COMMUTING, TRANLOCAL_CONSTRUCTING, TRANLOCAL_READ, TRANLOCAL_WRITE, TRANSACTIONTYPE_FAT_FIXED_LENGTH, TRANSACTIONTYPE_FAT_MONO, TRANSACTIONTYPE_FAT_VARIABLE_LENGTH, TRANSACTIONTYPE_LEAN_FIXED_LENGTH, TRANSACTIONTYPE_LEAN_MONO, TX_ABORTED, TX_ACTIVE, TX_COMMITTED, TX_PREPARED, TYPE_BOOLEAN, TYPE_DOUBLE, TYPE_INT, TYPE_LONG, TYPE_REF, VERSION_UNCOMMITTEDFields inherited from interface org.multiverse.MultiverseConstants
LOCKMODE_EXCLUSIVE, LOCKMODE_NONE, LOCKMODE_READ, LOCKMODE_WRITE, SHAKE_BUGS, SPIN_YIELD, TRACING_ENABLED -
Constructor Summary
ConstructorsConstructorDescriptionGammaTxnRef(E value) GammaTxnRef(GammaStm stm) GammaTxnRef(GammaStm stm, E value) GammaTxnRef(GammaTxn tx) GammaTxnRef(GammaTxn tx, E value) -
Method Summary
Modifier and TypeMethodDescriptionprivate Efinal EalterAndGet(Function<E> function) Alters the value stored in this Ref using the provided function and returns the result.final EalterAndGet(Txn tx, Function<E> function) Alters the value stored in this Ref using the provided function and lifting on the provided txn.final EalterAndGet(GammaTxn tx, Function<E> function) private EatomicAlter(Function<E> function, boolean returnOld) final EatomicAlterAndGet(Function<E> function) Atomically applies the function to the current value in this ref and returns the new value.final booleanatomicCompareAndSet(E expectedValue, E newValue) Executes a compare and set atomically.final EAtomically gets the value.final EatomicGetAndAlter(Function<E> function) Atomically applies the function to alter the value stored in this ref and returns the old value.final EatomicGetAndSet(E newValue) Atomically sets the value and returns the previous value.final booleanAtomically check if the current value is null.final EAtomically sets the value and returns the new value.final StringReturns a String representation of the object using the provided transaction without looking at aTxnThreadLocal.final EAtomically gets the value without providing any ordering guarantees.final voidAwaits for the value to become the given value.final voidAwaits until the predicate holds.final voidAwaits for the reference to become the given value.final voidAwaits until the predicate holds using the provided txn.final voidfinal voidfinal EAwaits for the value to become not null.final EAwaits for the value to become not null using the provided txn.final Efinal voidAwaits for the value to become null.final voidAwaits for the value to become not null using the provided txn.final voidfinal voidApplies the function on the ref in a commuting manner.final voidApplies the function on the ref in a commuting manner.final voidfinal Eget()Gets the value using the provided txn.final EGets the value using the provided txn.final Efinal EgetAndAlter(Function<E> function) Alters the value stored in this Ref using the provided function amd returns the old value.final EgetAndAlter(Txn tx, Function<E> function) Alters the value stored in this Ref using the function and returns the old value, using the provided txn.final EgetAndAlter(GammaTxn tx, Function<E> function) final EgetAndLock(LockMode lockMode) Gets the value and applies the lock.final EgetAndLock(Txn tx, LockMode lockMode) Gets the value using the provided txn and acquired the lock with the specified LockMode.final EgetAndLock(GammaTxn tx, LockMode lockMode) final ESets the value the value and returns the new value.final ESets the value using the provided txn.final Efinal EgetAndSetAndLock(E value, LockMode lockMode) Sets the value, acquired the Lock with the specified Lockmode and returns the previous value.final EgetAndSetAndLock(Txn tx, E value, LockMode lockMode) Sets the value and acquired the Lock with the provided LockMode.final EgetAndSetAndLock(GammaTxn tx, E value, LockMode lockMode) final booleanisNull()Checks if the current value is null.final booleanChecks if the current value is null using the provided txn.final booleanfinal ESets the new value.final ESets the new value using the provided txn.final Efinal EsetAndLock(E value, LockMode lockMode) Sets the new value and applies the lock.final EsetAndLock(Txn tx, E value, LockMode lockMode) Sets the new value using the provided txn.final EsetAndLock(GammaTxn tx, E value, LockMode lockMode) final StringReturns a debug representation of the TxnObject.final StringtoString()Returns a String representation of the Object using theTxnon theTxnThreadLocal.final StringReturns a String representation of the object using the providedTxn.final StringMethods inherited from class org.multiverse.stms.gamma.transactionalobjects.BaseGammaTxnRef
acquire, acquire, acquire, arriveAndExclusiveLockOrBackoff, atomicCompareAndSetLong, atomicGetLong, atomicObjectGet, atomicSetLong, atomicSetObject, commit, ensure, ensure, ensure, flattenCommute, getLong, getObject, hasReadConflict, leanCommit, load, openForCommute, openForCommute, openForCommute, openForCommute, openForConstruction, openForConstruction, openForConstruction, openForConstruction, openForRead, openForRead, openForRead, openForRead, openForRead, openForRead, openForWrite, openForWrite, openForWrite, openForWrite, openForWrite, openForWrite, prepare, registerChangeListener, releaseAfterFailure, releaseAfterReading, releaseAfterUpdate, setLong, setObject, tryLockAndCheckConflictMethods inherited from class org.multiverse.stms.gamma.transactionalobjects.AbstractGammaObject
___removeListenersAfterWrite, ___toOrecString, arrive, arriveAndExclusiveLock, arriveAndLock, atomicGetLockMode, atomicGetLockModeAsInt, departAfterFailure, departAfterFailureAndUnlock, departAfterReading, departAfterReadingAndUnlock, departAfterUpdateAndUnlock, getLock, getLockMode, getLockMode, getLockMode, getReadBiasedThreshold, getReadLockCount, getReadLockCount, getReadonlyCount, getReadonlyCount, getStm, getSurplus, getSurplus, getVersion, hasAnyLock, hasExclusiveLock, hasExclusiveLock, hasWriteLock, hasWriteLock, hasWriteOrExclusiveLock, identityHashCode, isReadBiased, isReadBiased, lockAfterArrive, setExclusiveLock, setIsReadBiased, setReadLockCount, setReadonlyCount, setSurplus, setWriteLock, unlockByUnregistered, upgradeReadLock, upgradeWriteLock, waitForExclusiveLockToBecomeFree
-
Constructor Details
-
GammaTxnRef
-
GammaTxnRef
-
GammaTxnRef
-
GammaTxnRef
-
GammaTxnRef
-
-
Method Details
-
get
Description copied from interface:TxnRefGets the value using the provided txn. -
get
Description copied from interface:TxnRefGets the value using the provided txn. -
get
-
getAndLock
Description copied from interface:TxnRefGets the value and applies the lock. If the current lockMode already is higher than the provided lockMode the Lock is not upgraded to a higher value.This call lifts on the
Txnstored in theTxnThreadLocal.- Specified by:
getAndLockin interfaceTxnRef<E>- Parameters:
lockMode- the LockMode applied.- Returns:
- the current value.
- See Also:
-
getAndLock
Description copied from interface:TxnRefGets the value using the provided txn and acquired the lock with the specified LockMode.- Specified by:
getAndLockin interfaceTxnRef<E>- Parameters:
tx- theTxnused for this operation.lockMode- the LockMode used- Returns:
- the value stored in the ref.
-
getAndLock
-
set
Description copied from interface:TxnRefSets the new value.This call lifts on the
Txnstored in theTxnThreadLocal. -
set
Description copied from interface:TxnRefSets the new value using the provided txn. -
set
-
setAndLock
Description copied from interface:TxnRefSets the new value and applies the lock.This call lifts on the
Txnstored in theTxnThreadLocal.- Specified by:
setAndLockin interfaceTxnRef<E>- Parameters:
value- the new value.lockMode- the used LockMode.- Returns:
- the new value.
-
setAndLock
Description copied from interface:TxnRefSets the new value using the provided txn.- Specified by:
setAndLockin interfaceTxnRef<E>- Parameters:
tx- theTxnused for this operation.value- the new valuelockMode- the lockMode used.- Returns:
- the old value
-
setAndLock
-
getAndSet
Description copied from interface:TxnRefSets the value the value and returns the new value.This call lifts on the
Txnstored in theTxnThreadLocal. -
getAndSet
Description copied from interface:TxnRefSets the value using the provided txn. -
getAndSet
-
getAndSetAndLock
Description copied from interface:TxnRefSets the value, acquired the Lock with the specified Lockmode and returns the previous value.This call lifts on the
Txnstored in theTxnThreadLocal.- Specified by:
getAndSetAndLockin interfaceTxnRef<E>- Parameters:
value- the new value.lockMode- the LockMode used.- Returns:
- the old value.
-
getAndSetAndLock
Description copied from interface:TxnRefSets the value and acquired the Lock with the provided LockMode.This call lifts on the
Txnstored in theTxnThreadLocal.- Specified by:
getAndSetAndLockin interfaceTxnRef<E>- Parameters:
tx- theTxnused for this operation.value- the new value.lockMode- the LockMode used.- Returns:
- the old value.
-
getAndSetAndLock
-
atomicGet
Description copied from interface:TxnRefAtomically gets the value. The value could be stale as soon as it is returned. This method doesn't care about any running txns. It could be that this call fails e.g. when a ref is locked. If you don't care about correct orderings, see theTxnRef.atomicWeakGet(). -
atomicWeakGet
Description copied from interface:TxnRefAtomically gets the value without providing any ordering guarantees. This method is extremely cheap and will never fail. So even if the ref is privatized, this call will still complete.It is the best method to call if you just want to get the current value stored.
- Specified by:
atomicWeakGetin interfaceTxnRef<E>- Returns:
- the value.
-
atomicSet
Description copied from interface:TxnRefAtomically sets the value and returns the new value. This method doesn't care about any running txns. -
atomicGetAndSet
Description copied from interface:TxnRefAtomically sets the value and returns the previous value. This method doesn't care about any running txns.- Specified by:
atomicGetAndSetin interfaceTxnRef<E>- Parameters:
newValue- the new value.- Returns:
- the old value.
-
commute
Description copied from interface:TxnRefApplies the function on the ref in a commuting manner. So if there are no dependencies, the function will commute. If somehow there already is a dependency or a dependency is formed on the result of the commuting function, the function will not commute and will be exactly the same as an alter.This is different than the behavior in Clojure where the commute will be re-applied at the end of the txn, even though some dependency is introduced, which can lead to inconsistencies.
This call lifts on the
Txnstored in theTxnThreadLocal. -
commute
Description copied from interface:TxnRefApplies the function on the ref in a commuting manner. So if there are no dependencies, the function will commute. If somehow there already is a dependency or a dependency is formed on the result of the commuting function, the function will not commute and will be exactly the same as an alter.This is different than the behavior in Clojure where the commute will be re-applied at the end of the txn, even though some dependency is introduced, which can lead to inconsistencies.
This call lifts on the
Txnstored in theTxnThreadLocal. -
commute
-
atomicAlterAndGet
Description copied from interface:TxnRefAtomically applies the function to the current value in this ref and returns the new value. This method doesn't care about any running txns.- Specified by:
atomicAlterAndGetin interfaceTxnRef<E>- Parameters:
function- the Function used- Returns:
- the new value.
-
atomicGetAndAlter
Description copied from interface:TxnRefAtomically applies the function to alter the value stored in this ref and returns the old value. This method doesn't care about any running txns.- Specified by:
atomicGetAndAlterin interfaceTxnRef<E>- Parameters:
function- the Function used- Returns:
- the old value.
-
atomicAlter
-
alterAndGet
Description copied from interface:TxnRefAlters the value stored in this Ref using the provided function and returns the result.This call lifts on the
Txnstored in theTxnThreadLocal.- Specified by:
alterAndGetin interfaceTxnRef<E>- Parameters:
function- the function that alters the value stored in this Ref.- Returns:
- the new value.
-
alterAndGet
Description copied from interface:TxnRefAlters the value stored in this Ref using the provided function and lifting on the provided txn.- Specified by:
alterAndGetin interfaceTxnRef<E>- Parameters:
tx- theTxnused for this operation.function- the function that alters the value stored in this Ref.- Returns:
- the new value.
-
alterAndGet
-
getAndAlter
Description copied from interface:TxnRefAlters the value stored in this Ref using the provided function amd returns the old value.This call lifts on the
Txnstored in theTxnThreadLocal.- Specified by:
getAndAlterin interfaceTxnRef<E>- Parameters:
function- the function that alters the value stored in this Ref.- Returns:
- the old value.
-
getAndAlter
Description copied from interface:TxnRefAlters the value stored in this Ref using the function and returns the old value, using the provided txn.- Specified by:
getAndAlterin interfaceTxnRef<E>- Parameters:
tx- theTxnused for this operation.function- the function that alters the value stored in this Ref.- Returns:
- the old value
-
getAndAlter
-
alter
-
atomicCompareAndSet
Description copied from interface:TxnRefExecutes a compare and set atomically. This method doesn't care about any running txns.- Specified by:
atomicCompareAndSetin interfaceTxnRef<E>- Parameters:
expectedValue- the expected value.newValue- the new value.- Returns:
- true if the compareAndSwap was a success, false otherwise.
-
isNull
public final boolean isNull()Description copied from interface:TxnRefChecks if the current value is null.This call lifts on the
Txnstored in theTxnThreadLocal. -
isNull
Description copied from interface:TxnRefChecks if the current value is null using the provided txn. -
isNull
-
atomicIsNull
public final boolean atomicIsNull()Description copied from interface:TxnRefAtomically check if the current value is null. This method doesn't care about any running txns.- Specified by:
atomicIsNullin interfaceTxnRef<E>- Returns:
- true if null, false otherwise.
-
awaitNotNullAndGet
Description copied from interface:TxnRefAwaits for the value to become not null. If the value already is not null, this call returns the stored value. If the value is null, a retry is done.This call lifts on the
Txnstored in theTxnThreadLocal.- Specified by:
awaitNotNullAndGetin interfaceTxnRef<E>- Returns:
- the stored value.
-
awaitNotNullAndGet
Description copied from interface:TxnRefAwaits for the value to become not null using the provided txn. If the value already is not null, this call returns the stored value. If the value is null, a retry is done.- Specified by:
awaitNotNullAndGetin interfaceTxnRef<E>- Parameters:
tx- theTxnused for this operation.- Returns:
- the stored value.
-
awaitNotNullAndGet
-
awaitNull
public final void awaitNull()Description copied from interface:TxnRefAwaits for the value to become null. If the value already is null, this call continues. If the reference is not null, a retry is done.This call lifts on the
Txnstored in theTxnThreadLocal. -
awaitNull
Description copied from interface:TxnRefAwaits for the value to become not null using the provided txn. If the value already is null, this call continues. If the value is not null, a retry is done. -
awaitNull
-
await
Description copied from interface:TxnRefAwaits for the value to become the given value. If the value already has the the specified value, the call continues, else a retry is done.This call lifts on the
Txnstored in theTxnThreadLocal. -
await
Description copied from interface:TxnRefAwaits for the reference to become the given value. If the value already has the the specified value, the call continues, else a retry is done. -
await
-
await
Description copied from interface:TxnRefAwaits until the predicate holds. If the value already evaluates to true, the call continues else a retry is done. If the predicate throws an exception, the txn is aborted and the throwable is propagated.This call lifts on the
Txnstored in theTxnThreadLocal. -
await
Description copied from interface:TxnRefAwaits until the predicate holds using the provided txn. If the value already evaluates to true, the call continues else a retry is done. If the predicate throws an exception, the txn is aborted and the throwable is propagated. -
await
-
toDebugString
Description copied from interface:TxnObjectReturns 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.- Specified by:
toDebugStringin interfaceTxnObject- Returns:
- the debug representation of the TxnObject.
-
toString
Description copied from interface:TxnObjectReturns a String representation of the Object using theTxnon theTxnThreadLocal. -
toString
Description copied from interface:TxnObjectReturns a String representation of the object using the providedTxn. -
toString
-
atomicToString
Description copied from interface:TxnObjectReturns 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.- Specified by:
atomicToStringin interfaceTxnObject- Returns:
- the String representation.
-