public class GammaTxnInteger extends BaseGammaTxnRef implements TxnInteger
long_value, ref_value, type
___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, version
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_UNCOMMITTED
LOCKMODE_EXCLUSIVE, LOCKMODE_NONE, LOCKMODE_READ, LOCKMODE_WRITE, SHAKE_BUGS, SPIN_YIELD, TRACING_ENABLED
Constructor and Description |
---|
GammaTxnInteger(GammaStm stm) |
GammaTxnInteger(GammaStm stm,
int value) |
GammaTxnInteger(GammaTxn tx) |
GammaTxnInteger(GammaTxn tx,
int value) |
GammaTxnInteger(int value) |
Modifier and Type | Method and Description |
---|---|
int |
alterAndGet(GammaTxn tx,
IntFunction function) |
int |
alterAndGet(IntFunction function)
Alters the value stored in this Ref using the provided function and returns the result.
|
int |
alterAndGet(Txn tx,
IntFunction function)
Alters the value stored in this Ref using the provided function and lifting on the provided txn.
|
int |
atomicAlterAndGet(IntFunction function)
Atomically applies the function to the current value in this ref and returns the new value.
|
boolean |
atomicCompareAndSet(int expectedValue,
int newValue)
Executes a compare and set atomically.
|
int |
atomicGet()
Atomically gets the value.
|
int |
atomicGetAndAlter(IntFunction function)
Atomically applies the function to alter the value stored in this ref and returns the old value.
|
int |
atomicGetAndIncrement(int amount)
Atomically increments the value and returns the old value.
|
int |
atomicGetAndSet(int newValue)
Atomically sets the value and returns the previous value.
|
int |
atomicIncrementAndGet(int amount)
Atomically increments the value and returns the old value.
|
int |
atomicSet(int newValue)
Atomically sets the value and returns the new value.
|
String |
atomicToString()
Returns a String representation of the object using the provided transaction without looking
at a
TxnThreadLocal . |
int |
atomicWeakGet()
Atomically gets the value without providing any ordering guarantees.
|
void |
await(GammaTxn tx,
int value) |
void |
await(GammaTxn tx,
IntPredicate predicate) |
void |
await(int value)
Awaits for the value to become the given value.
|
void |
await(IntPredicate predicate)
Awaits until the predicate holds.
|
void |
await(Txn tx,
int value)
Awaits for the reference to become the given value.
|
void |
await(Txn tx,
IntPredicate predicate)
Awaits until the predicate holds using the provided txn.
|
void |
commute(GammaTxn tx,
IntFunction function) |
void |
commute(IntFunction function)
Applies the function on the ref in a commuting manner.
|
void |
commute(Txn tx,
IntFunction function)
Applies the function on the ref in a commuting manner.
|
void |
decrement()
Decrements the value by one.
|
void |
decrement(int amount)
Decrements the value by the given amount.
|
void |
decrement(Txn tx)
Decrements the value by one using the provided txn.
|
void |
decrement(Txn tx,
int amount)
Decrements the value by the given amount using the provided txn.
|
int |
get()
Gets the value using the provided txn.
|
int |
get(GammaTxn tx) |
int |
get(Txn tx)
Gets the value using the provided txn.
|
int |
getAndAlter(GammaTxn tx,
IntFunction function) |
int |
getAndAlter(IntFunction function)
Alters the value stored in this Ref using the provided function amd returns the old value.
|
int |
getAndAlter(Txn tx,
IntFunction function)
Alters the value stored in this Ref using the function and returns the old value, using the provided txn.
|
int |
getAndIncrement(GammaTxn tx,
int amount) |
int |
getAndIncrement(int amount)
Increments the value and returns the old value.
|
int |
getAndIncrement(Txn tx,
int amount)
Increments the value and returns the old value using the provided txn.
|
int |
getAndLock(GammaTxn tx,
LockMode lockMode) |
int |
getAndLock(LockMode lockMode)
Gets the value and applies the lock.
|
int |
getAndLock(Txn tx,
LockMode lockMode)
Gets the value using the provided txn and acquired the lock with the specified LockMode.
|
int |
getAndSet(GammaTxn tx,
int value) |
int |
getAndSet(int value)
Sets the value the value and returns the new value.
|
int |
getAndSet(Txn tx,
int value)
Sets the value using the provided txn.
|
int |
getAndSetAndLock(int value,
LockMode lockMode)
Sets the value, acquired the Lock with the specified Lockmode and returns the previous value.
|
int |
getAndSetAndLock(Txn tx,
int value,
LockMode lockMode)
Sets the value and acquired the Lock with the provided LockMode.
|
int |
getAndSetLock(GammaTxn tx,
int value,
LockMode lockMode) |
void |
increment()
Increments the value by one.
|
void |
increment(GammaTxn tx,
int amount) |
void |
increment(int amount)
Increments the value by the given amount.
|
void |
increment(Txn tx)
Increments the value by one using the provided txn.
|
void |
increment(Txn tx,
int amount)
Increments the value by the given amount using the provided txn.
|
int |
incrementAndGet(GammaTxn tx,
int amount) |
int |
incrementAndGet(int amount)
Increments and gets the new value.
|
int |
incrementAndGet(Txn tx,
int amount)
Increments and gets the new value using the provided txn.
|
int |
set(GammaTxn tx,
int value) |
int |
set(int value)
Sets the new value.
|
int |
set(Txn tx,
int value)
Sets the new value using the provided txn.
|
int |
setAndLock(GammaTxn tx,
int value,
LockMode lockMode) |
int |
setAndLock(int value,
LockMode lockMode)
Sets the new value and applies the lock.
|
int |
setAndLock(Txn tx,
int value,
LockMode lockMode)
Sets the new value using the provided txn.
|
String |
toDebugString()
Returns a debug representation of the TxnObject.
|
String |
toString()
Returns a String representation of the Object using the
Txn on the TxnThreadLocal . |
String |
toString(GammaTxn tx) |
String |
toString(Txn tx)
Returns a String representation of the object using the provided
Txn . |
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, tryLockAndCheckConflict
___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
public GammaTxnInteger(int value)
public GammaTxnInteger(GammaTxn tx)
public GammaTxnInteger(GammaTxn tx, int value)
public GammaTxnInteger(GammaStm stm)
public GammaTxnInteger(GammaStm stm, int value)
public final int get()
TxnInteger
get
in interface TxnInteger
TxnInteger.atomicGet()
public final int get(Txn tx)
TxnInteger
get
in interface TxnInteger
tx
- the Txn
used for this operation.public final int get(GammaTxn tx)
public int getAndLock(LockMode lockMode)
TxnInteger
This call lifts on the Txn
stored in the TxnThreadLocal
.
getAndLock
in interface TxnInteger
lockMode
- the LockMode applied.TxnInteger.atomicGet()
public final int getAndLock(Txn tx, LockMode lockMode)
TxnInteger
getAndLock
in interface TxnInteger
tx
- the Txn
used for this operation.lockMode
- the LockMode usedpublic final int set(int value)
TxnInteger
This call lifts on the Txn
stored in the TxnThreadLocal
.
set
in interface TxnInteger
value
- the new value.public final int set(Txn tx, int value)
TxnInteger
set
in interface TxnInteger
tx
- the Txn
used for this operation.value
- the new valuepublic final int set(GammaTxn tx, int value)
public final int setAndLock(int value, LockMode lockMode)
TxnInteger
This call lifts on the Txn
stored in the TxnThreadLocal
.
setAndLock
in interface TxnInteger
value
- the new value.lockMode
- the used LockMode.public final int setAndLock(Txn tx, int value, LockMode lockMode)
TxnInteger
setAndLock
in interface TxnInteger
tx
- the Txn
used for this operation.value
- the new valuelockMode
- the lockMode used.public final int getAndSet(int value)
TxnInteger
This call lifts on the Txn
stored in the TxnThreadLocal
.
getAndSet
in interface TxnInteger
value
- the new value.public final int getAndSet(Txn tx, int value)
TxnInteger
getAndSet
in interface TxnInteger
tx
- the Txn
used for this operation.value
- the new value.public final int getAndSet(GammaTxn tx, int value)
public final int getAndSetAndLock(int value, LockMode lockMode)
TxnInteger
This call lifts on the Txn
stored in the TxnThreadLocal
.
getAndSetAndLock
in interface TxnInteger
value
- the new value.lockMode
- the LockMode used.public final int getAndSetAndLock(Txn tx, int value, LockMode lockMode)
TxnInteger
This call lifts on the Txn
stored in the TxnThreadLocal
.
getAndSetAndLock
in interface TxnInteger
tx
- the Txn
used for this operation.value
- the new value.lockMode
- the LockMode used.public final int atomicGet()
TxnInteger
TxnInteger.atomicWeakGet()
.atomicGet
in interface TxnInteger
public final int atomicWeakGet()
TxnInteger
It is the best method to call if you just want to get the current value stored.
atomicWeakGet
in interface TxnInteger
public final int atomicSet(int newValue)
TxnInteger
atomicSet
in interface TxnInteger
newValue
- the new value.public final int atomicGetAndSet(int newValue)
TxnInteger
atomicGetAndSet
in interface TxnInteger
newValue
- the new value.public final void commute(IntFunction function)
TxnInteger
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 Txn
stored in the TxnThreadLocal
.
commute
in interface TxnInteger
function
- the function to apply to this reference.public final void commute(Txn tx, IntFunction function)
TxnInteger
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 Txn
stored in the TxnThreadLocal
.
commute
in interface TxnInteger
tx
- the Txn
used for this operation.function
- the function to apply to this reference.public final void commute(GammaTxn tx, IntFunction function)
public final int atomicAlterAndGet(IntFunction function)
TxnInteger
atomicAlterAndGet
in interface TxnInteger
function
- the Function usedpublic final int atomicGetAndAlter(IntFunction function)
TxnInteger
atomicGetAndAlter
in interface TxnInteger
function
- the Function usedpublic final int alterAndGet(IntFunction function)
TxnInteger
This call lifts on the Txn
stored in the TxnThreadLocal
.
alterAndGet
in interface TxnInteger
function
- the function that alters the value stored in this Ref.public final int alterAndGet(Txn tx, IntFunction function)
TxnInteger
alterAndGet
in interface TxnInteger
tx
- the Txn
used for this operation.function
- the function that alters the value stored in this Ref.public final int alterAndGet(GammaTxn tx, IntFunction function)
public final int getAndAlter(IntFunction function)
TxnInteger
This call lifts on the Txn
stored in the TxnThreadLocal
.
getAndAlter
in interface TxnInteger
function
- the function that alters the value stored in this Ref.public final int getAndAlter(Txn tx, IntFunction function)
TxnInteger
getAndAlter
in interface TxnInteger
tx
- the Txn
used for this operation.function
- the function that alters the value stored in this Ref.public final int getAndAlter(GammaTxn tx, IntFunction function)
public final boolean atomicCompareAndSet(int expectedValue, int newValue)
TxnInteger
atomicCompareAndSet
in interface TxnInteger
expectedValue
- the expected value.newValue
- the new value.public final int atomicGetAndIncrement(int amount)
TxnInteger
atomicGetAndIncrement
in interface TxnInteger
amount
- the amount to increase with.public final int atomicIncrementAndGet(int amount)
TxnInteger
atomicIncrementAndGet
in interface TxnInteger
amount
- the amount to increment with.public final int getAndIncrement(int amount)
TxnInteger
This call lifts on the Txn
stored in the TxnThreadLocal
.
getAndIncrement
in interface TxnInteger
amount
- the amount to increment with.public final int getAndIncrement(Txn tx, int amount)
TxnInteger
getAndIncrement
in interface TxnInteger
tx
- the Txn
used for this operation.amount
- the amount to increment with.public final int getAndIncrement(GammaTxn tx, int amount)
public final int incrementAndGet(int amount)
TxnInteger
This call lifts on the Txn
stored in the TxnThreadLocal
.
incrementAndGet
in interface TxnInteger
amount
- the amount to increment with.public final int incrementAndGet(Txn tx, int amount)
TxnInteger
incrementAndGet
in interface TxnInteger
tx
- the Txn
used for this operation.amount
- the amount to increment with.public final int incrementAndGet(GammaTxn tx, int amount)
public final void increment()
TxnInteger
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 Txn
stored in the TxnThreadLocal
.
increment
in interface TxnInteger
public final void increment(Txn tx)
TxnInteger
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
in interface TxnInteger
tx
- the Txn
used for this operation.public final void increment(int amount)
TxnInteger
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 Txn
stored in the TxnThreadLocal
.
increment
in interface TxnInteger
amount
- the amount to increase withpublic final void increment(Txn tx, int amount)
TxnInteger
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
in interface TxnInteger
tx
- the Txn
used for this operation.amount
- the amount to increment withpublic final void increment(GammaTxn tx, int amount)
public final void decrement()
TxnInteger
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 Txn
stored in the TxnThreadLocal
.
decrement
in interface TxnInteger
public final void decrement(Txn tx)
TxnInteger
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
in interface TxnInteger
tx
- the Txn
used for this operation.public final void decrement(int amount)
TxnInteger
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 Txn
stored in the TxnThreadLocal
.
decrement
in interface TxnInteger
amount
- the amount to decrement withpublic final void decrement(Txn tx, int amount)
TxnInteger
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
in interface TxnInteger
tx
- the Txn
used for this operation.amount
- the amount to decrement withpublic final void await(int value)
TxnInteger
This call lifts on the Txn
stored in the TxnThreadLocal
.
await
in interface TxnInteger
value
- the value to wait for.public final void await(Txn tx, int value)
TxnInteger
await
in interface TxnInteger
tx
- the Txn
used for this operation.value
- the value to wait for.public final void await(GammaTxn tx, int value)
public final void await(IntPredicate predicate)
TxnInteger
This call lifts on the Txn
stored in the TxnThreadLocal
.
await
in interface TxnInteger
predicate
- the predicate to evaluate.public final void await(Txn tx, IntPredicate predicate)
TxnInteger
await
in interface TxnInteger
tx
- the Txn
used for this operation.predicate
- the predicate to evaluate.public final void await(GammaTxn tx, IntPredicate predicate)
public final String toDebugString()
TxnObject
toDebugString
in interface TxnObject
public final String toString()
TxnObject
Txn
on the TxnThreadLocal
.public final String toString(Txn tx)
TxnObject
Txn
.public final String atomicToString()
TxnObject
TxnThreadLocal
. The outputted value doesn't need to be consistent from some point
in time, only a best effort is made.atomicToString
in interface TxnObject
Copyright © 2020. All rights reserved.