Class GammaTxnLong
- All Implemented Interfaces:
Lock, TxnLong, TxnObject, MultiverseConstants, GammaConstants, GammaObject
-
Field Summary
Fields inherited from class BaseGammaTxnRef
long_value, ref_value, typeFields inherited from class 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 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 MultiverseConstants
LOCKMODE_EXCLUSIVE, LOCKMODE_NONE, LOCKMODE_READ, LOCKMODE_WRITE, SHAKE_BUGS, SPIN_YIELD, TRACING_ENABLED -
Constructor Summary
ConstructorsConstructorDescriptionGammaTxnLong(long value) GammaTxnLong(GammaStm stm) GammaTxnLong(GammaStm stm, long initialValue) GammaTxnLong(GammaTxn tx) GammaTxnLong(GammaTxn tx, long value) -
Method Summary
Modifier and TypeMethodDescriptionprivate longalter(GammaTxn tx, LongFunction function, boolean returnOld) final longalterAndGet(LongFunction function) Alters the value stored in this Ref using the provided function and returns the result.final longalterAndGet(Txn tx, LongFunction function) Alters the value stored in this Ref using the provided function and lifting on the provided txn.final longalterAndGet(GammaTxn tx, LongFunction function) private longatomicAlter(LongFunction function, boolean returnOld) final longatomicAlterAndGet(LongFunction function) Atomically applies the function to the current value in this ref and returns the new value.final booleanatomicCompareAndSet(long expectedValue, long newValue) Executes a compare and set atomically.final longAtomically gets the value.final longatomicGetAndAlter(LongFunction function) Atomically applies the function to alter the value stored in this ref and returns the old value.final longatomicGetAndIncrement(long amount) Atomically increments the value and returns the old value.final longatomicGetAndSet(long newValue) Atomically sets the value and returns the previous value.final longatomicIncrementAndGet(long amount) Atomically increments the value and returns the old value.final longatomicSet(long newValue) Atomically 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 longAtomically gets the value without providing any ordering guarantees.final voidawait(long value) Awaits for the value to become the given value.final voidawait(LongPredicate predicate) Awaits until the predicate holds.final voidAwaits for the reference to become the given value.final voidawait(Txn tx, LongPredicate predicate) Awaits until the predicate holds using the provided txn.final voidfinal voidawait(GammaTxn tx, LongPredicate predicate) final voidcommute(LongFunction function) Applies the function on the ref in a commuting manner.final voidcommute(Txn tx, LongFunction function) Applies the function on the ref in a commuting manner.final voidcommute(GammaTxn tx, LongFunction function) final voidDecrements the value by one.final voiddecrement(long amount) Decrements the value by the given amount.final voidDecrements the value by one using the provided txn.final voidDecrements the value by the given amount using the provided txn.final longget()Gets the value using the provided txn.final longGets the value using the provided txn.final longfinal longgetAndAlter(LongFunction function) Alters the value stored in this Ref using the provided function amd returns the old value.final longgetAndAlter(Txn tx, LongFunction function) Alters the value stored in this Ref using the function and returns the old value, using the provided txn.final longgetAndAlter(GammaTxn tx, LongFunction function) final longgetAndIncrement(long amount) Increments the value and returns the old value.final longgetAndIncrement(Txn tx, long amount) Increments the value and returns the old value using the provided txn.final longgetAndIncrement(GammaTxn tx, long amount) final longgetAndLock(LockMode lockMode) Gets the value and applies the lock.final longgetAndLock(Txn tx, LockMode lockMode) Gets the value using the provided txn and acquired the lock with the specified LockMode.final longgetAndLock(GammaTxn tx, LockMode lockMode) final longgetAndSet(long value) Sets the value the value and returns the new value.final longSets the value using the provided txn.final longfinal longgetAndSetAndLock(long value, LockMode lockMode) Sets the value, acquired the Lock with the specified Lockmode and returns the previous value.final longgetAndSetAndLock(Txn tx, long value, LockMode lockMode) Sets the value and acquired the Lock with the provided LockMode.final longgetAndSetLock(GammaTxn tx, long value, LockMode lockMode) final voidIncrements the value by one.final voidincrement(long amount) Increments the value by the given amount.final voidIncrements the value by one using the provided txn.final voidIncrements the value by the given amount using the provided txn.final voidfinal longincrementAndGet(long amount) Increments and gets the new value.final longincrementAndGet(Txn tx, long amount) Increments and gets the new value using the provided txn.final longincrementAndGet(GammaTxn tx, long amount) final longset(long value) Sets the new value.final longSets the new value using the provided txn.final longfinal longsetAndLock(long value, LockMode lockMode) Sets the new value and applies the lock.final longsetAndLock(Txn tx, long value, LockMode lockMode) Sets the new value using the provided txn.final longsetAndLock(GammaTxn tx, long 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 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 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
-
GammaTxnLong
public GammaTxnLong(long value) -
GammaTxnLong
-
GammaTxnLong
-
GammaTxnLong
-
GammaTxnLong
-
-
Method Details
-
get
-
get
-
get
-
getAndLock
Description copied from interface:TxnLongGets 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 interfaceTxnLong- Parameters:
lockMode- the LockMode applied.- Returns:
- the current value.
- See Also:
-
getAndLock
Description copied from interface:TxnLongGets the value using the provided txn and acquired the lock with the specified LockMode.- Specified by:
getAndLockin interfaceTxnLong- Parameters:
tx- theTxnused for this operation.lockMode- the LockMode used- Returns:
- the value stored in the ref.
-
getAndLock
-
set
public final long set(long value) Description copied from interface:TxnLongSets the new value.This call lifts on the
Txnstored in theTxnThreadLocal. -
set
-
set
-
setAndLock
Description copied from interface:TxnLongSets the new value and applies the lock.This call lifts on the
Txnstored in theTxnThreadLocal.- Specified by:
setAndLockin interfaceTxnLong- Parameters:
value- the new value.lockMode- the used LockMode.- Returns:
- the new value.
-
setAndLock
Description copied from interface:TxnLongSets the new value using the provided txn.- Specified by:
setAndLockin interfaceTxnLong- Parameters:
tx- theTxnused for this operation.value- the new valuelockMode- the lockMode used.- Returns:
- the old value
-
setAndLock
-
getAndSet
public final long getAndSet(long value) Description copied from interface:TxnLongSets the value the value and returns the new value.This call lifts on the
Txnstored in theTxnThreadLocal. -
getAndSet
-
getAndSet
-
getAndSetAndLock
Description copied from interface:TxnLongSets 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 interfaceTxnLong- Parameters:
value- the new value.lockMode- the LockMode used.- Returns:
- the old value.
-
getAndSetAndLock
Description copied from interface:TxnLongSets the value and acquired the Lock with the provided LockMode.This call lifts on the
Txnstored in theTxnThreadLocal.- Specified by:
getAndSetAndLockin interfaceTxnLong- Parameters:
tx- theTxnused for this operation.value- the new value.lockMode- the LockMode used.- Returns:
- the old value.
-
getAndSetLock
-
atomicGet
public final long atomicGet()Description copied from interface:TxnLongAtomically 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 theTxnLong.atomicWeakGet(). -
atomicWeakGet
public final long atomicWeakGet()Description copied from interface:TxnLongAtomically 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 interfaceTxnLong- Returns:
- the value.
-
atomicSet
-
atomicGetAndSet
public final long atomicGetAndSet(long newValue) Description copied from interface:TxnLongAtomically sets the value and returns the previous value. This method doesn't care about any running txns.- Specified by:
atomicGetAndSetin interfaceTxnLong- Parameters:
newValue- the new value.- Returns:
- the old value.
-
commute
Description copied from interface:TxnLongApplies 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:TxnLongApplies 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:TxnLongAtomically 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 interfaceTxnLong- Parameters:
function- the Function used- Returns:
- the new value.
-
atomicAlter
-
alterAndGet
Description copied from interface:TxnLongAlters 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 interfaceTxnLong- Parameters:
function- the function that alters the value stored in this Ref.- Returns:
- the new value.
-
alterAndGet
Description copied from interface:TxnLongAlters the value stored in this Ref using the provided function and lifting on the provided txn.- Specified by:
alterAndGetin interfaceTxnLong- Parameters:
tx- theTxnused for this operation.function- the function that alters the value stored in this Ref.- Returns:
- the new value.
-
alterAndGet
-
atomicGetAndAlter
Description copied from interface:TxnLongAtomically 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 interfaceTxnLong- Parameters:
function- the Function used- Returns:
- the old value.
-
getAndAlter
Description copied from interface:TxnLongAlters 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 interfaceTxnLong- Parameters:
function- the function that alters the value stored in this Ref.- Returns:
- the old value.
-
getAndAlter
Description copied from interface:TxnLongAlters the value stored in this Ref using the function and returns the old value, using the provided txn.- Specified by:
getAndAlterin interfaceTxnLong- Parameters:
tx- theTxnused for this operation.function- the function that alters the value stored in this Ref.- Returns:
- the old value
-
getAndAlter
-
alter
-
atomicCompareAndSet
public final boolean atomicCompareAndSet(long expectedValue, long newValue) Description copied from interface:TxnLongExecutes a compare and set atomically. This method doesn't care about any running txns.- Specified by:
atomicCompareAndSetin interfaceTxnLong- Parameters:
expectedValue- the expected value.newValue- the new value.- Returns:
- true if the compareAndSwap was a success, false otherwise.
-
atomicGetAndIncrement
public final long atomicGetAndIncrement(long amount) Description copied from interface:TxnLongAtomically increments the value and returns the old value. This method doesn't care about any running txns.- Specified by:
atomicGetAndIncrementin interfaceTxnLong- Parameters:
amount- the amount to increase with.- Returns:
- the old value.
-
getAndIncrement
public final long getAndIncrement(long amount) Description copied from interface:TxnLongIncrements the value and returns the old value.This call lifts on the
Txnstored in theTxnThreadLocal.- Specified by:
getAndIncrementin interfaceTxnLong- Parameters:
amount- the amount to increment with.- Returns:
- the old value.
-
getAndIncrement
Description copied from interface:TxnLongIncrements the value and returns the old value using the provided txn.- Specified by:
getAndIncrementin interfaceTxnLong- Parameters:
tx- theTxnused for this operation.amount- the amount to increment with.- Returns:
- the old value.
-
getAndIncrement
-
atomicIncrementAndGet
public final long atomicIncrementAndGet(long amount) Description copied from interface:TxnLongAtomically increments the value and returns the old value. This method doesn't care about any running txns.- Specified by:
atomicIncrementAndGetin interfaceTxnLong- Parameters:
amount- the amount to increment with.- Returns:
- the new value.
-
incrementAndGet
public final long incrementAndGet(long amount) Description copied from interface:TxnLongIncrements and gets the new value.This call lifts on the
Txnstored in theTxnThreadLocal.- Specified by:
incrementAndGetin interfaceTxnLong- Parameters:
amount- the amount to increment with.- Returns:
- the new value.
-
incrementAndGet
Description copied from interface:TxnLongIncrements and gets the new value using the provided txn.- Specified by:
incrementAndGetin interfaceTxnLong- Parameters:
tx- theTxnused for this operation.amount- the amount to increment with.- Returns:
- the new value.
-
incrementAndGet
-
increment
public final void increment()Description copied from interface:TxnLongIncrements the value by one.This call is able to commute if there are no dependencies on the value in the txn. That is why this method doesn't have a return value.
This call lifts on the
Txnstored in theTxnThreadLocal. -
increment
Description copied from interface:TxnLongIncrements the value by one using the provided txn.This call is able to commute if there are no dependencies on the value in the txn. That is why this method doesn't have a return value.
-
increment
-
increment
public final void increment(long amount) Description copied from interface:TxnLongIncrements the value by the given amount.This call is able to commute if there are no dependencies on the value in the txn. That is why this method doesn't have a return value.
This call lifts on the
Txnstored in theTxnThreadLocal. -
increment
Description copied from interface:TxnLongIncrements the value by the given amount using the provided txn.This call is able to commute if there are no dependencies on the value in the txn. That is why this method doesn't have a return value.
-
decrement
public final void decrement()Description copied from interface:TxnLongDecrements the value by one.This call is able to commute if there are no dependencies on the value in the txn. That is why this method doesn't have a return value.
This call lifts on the
Txnstored in theTxnThreadLocal. -
decrement
Description copied from interface:TxnLongDecrements the value by one using the provided txn.This call is able to commute if there are no dependencies on the value in the txn. That is why this method doesn't have a return value.
-
decrement
public final void decrement(long amount) Description copied from interface:TxnLongDecrements the value by the given amount.This call is able to commute if there are no dependencies on the value in the txn. That is why this method doesn't have a return value.
This call lifts on the
Txnstored in theTxnThreadLocal. -
decrement
Description copied from interface:TxnLongDecrements the value by the given amount using the provided txn.This call is able to commute if there are no dependencies on the value in the txn. That is why this method doesn't have a return value.
-
await
public final void await(long value) Description copied from interface:TxnLongAwaits 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:TxnLongAwaits 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:TxnLongAwaits 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:TxnLongAwaits 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
-
toString
-
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.
-