Class GammaTxnBoolean
- java.lang.Object
-
- org.multiverse.stms.gamma.transactionalobjects.AbstractGammaObject
-
- org.multiverse.stms.gamma.transactionalobjects.BaseGammaTxnRef
-
- org.multiverse.stms.gamma.transactionalobjects.GammaTxnBoolean
-
- All Implemented Interfaces:
Lock,TxnBoolean,TxnObject,MultiverseConstants,GammaConstants,GammaObject
public class GammaTxnBoolean extends BaseGammaTxnRef implements TxnBoolean
ATxnBooleanfor theGammaStm.
-
-
Field Summary
-
Fields inherited from class org.multiverse.stms.gamma.transactionalobjects.BaseGammaTxnRef
long_value, ref_value, type
-
Fields 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, version
-
Fields 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_UNCOMMITTED
-
Fields inherited from interface org.multiverse.MultiverseConstants
LOCKMODE_EXCLUSIVE, LOCKMODE_NONE, LOCKMODE_READ, LOCKMODE_WRITE, SHAKE_BUGS, SPIN_YIELD, TRACING_ENABLED
-
-
Constructor Summary
Constructors Constructor Description GammaTxnBoolean(boolean value)GammaTxnBoolean(GammaStm stm)GammaTxnBoolean(GammaStm stm, boolean b)GammaTxnBoolean(GammaTxn tx)GammaTxnBoolean(GammaTxn tx, boolean value)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanalter(GammaTxn tx, BooleanFunction function, boolean returnOld)booleanalterAndGet(BooleanFunction function)Alters the value stored in this Ref using the provided function and returns the result.booleanalterAndGet(Txn tx, BooleanFunction function)Alters the value stored in this Ref using the provided function and lifting on the provided txn.booleanalterAndGet(GammaTxn tx, BooleanFunction function)private booleanatomicAlter(BooleanFunction function, boolean returnOld)booleanatomicAlterAndGet(BooleanFunction function)Atomically applies the function to the current value in this ref and returns the new value.booleanatomicCompareAndSet(boolean expectedValue, boolean newValue)Executes a compare and set atomically.booleanatomicGet()Atomically gets the value.booleanatomicGetAndAlter(BooleanFunction function)Atomically applies the function to alter the value stored in this ref and returns the old value.booleanatomicGetAndSet(boolean newValue)Atomically sets the value and returns the previous value.booleanatomicSet(boolean newValue)Atomically sets the value and returns the new value.java.lang.StringatomicToString()Returns a String representation of the object using the provided transaction without looking at aTxnThreadLocal.booleanatomicWeakGet()Atomically gets the value without providing any ordering guarantees.voidawait(boolean value)Awaits for the value to become the given value.voidawait(BooleanPredicate predicate)Awaits until the predicate holds.voidawait(Txn tx, boolean value)Awaits for the reference to become the given value.voidawait(Txn tx, BooleanPredicate predicate)Awaits until the predicate holds using the provided txn.voidawait(GammaTxn tx, boolean value)voidawait(GammaTxn tx, BooleanPredicate predicate)voidcommute(BooleanFunction function)Applies the function on the ref in a commuting manner.voidcommute(Txn tx, BooleanFunction function)Applies the function on the ref in a commuting manner.voidcommute(GammaTxn tx, BooleanFunction function)booleanget()Gets the value using the provided txn.booleanget(Txn tx)Gets the value using the provided txn.booleanget(GammaTxn tx)booleangetAndAlter(BooleanFunction function)Alters the value stored in this Ref using the provided function amd returns the old value.booleangetAndAlter(Txn tx, BooleanFunction function)Alters the value stored in this Ref using the function and returns the old value, using the provided txn.booleangetAndAlter(GammaTxn tx, BooleanFunction function)booleangetAndLock(LockMode lockMode)Gets the value and applies the lock.booleangetAndLock(Txn tx, LockMode lockMode)Gets the value using the provided txn and acquired the lock with the specified LockMode.booleangetAndLock(GammaTxn tx, LockMode lockMode)booleangetAndSet(boolean value)Sets the value the value and returns the new value.booleangetAndSet(Txn tx, boolean value)Sets the value using the provided txn.booleangetAndSet(GammaTxn tx, boolean value)booleangetAndSetAndLock(boolean value, LockMode lockMode)Sets the value, acquired the Lock with the specified Lockmode and returns the previous value.booleangetAndSetAndLock(Txn tx, boolean value, LockMode lockMode)Sets the value and acquired the Lock with the provided LockMode.booleangetAndSetAndLock(GammaTxn tx, boolean value, LockMode lockMode)booleanset(boolean value)Sets the new value.booleanset(Txn tx, boolean value)Sets the new value using the provided txn.booleanset(GammaTxn tx, boolean value)booleansetAndLock(boolean value, LockMode lockMode)Sets the new value and applies the lock.booleansetAndLock(Txn tx, boolean value, LockMode lockMode)Sets the new value using the provided txn.booleansetAndLock(GammaTxn tx, boolean value, LockMode lockMode)java.lang.StringtoDebugString()Returns a debug representation of the TxnObject.java.lang.StringtoString()Returns a String representation of the Object using theTxnon theTxnThreadLocal.java.lang.StringtoString(Txn tx)Returns a String representation of the object using the providedTxn.java.lang.StringtoString(GammaTxn tx)-
Methods 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, tryLockAndCheckConflict
-
Methods 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 Detail
-
GammaTxnBoolean
public GammaTxnBoolean(boolean value)
-
GammaTxnBoolean
public GammaTxnBoolean(GammaTxn tx)
-
GammaTxnBoolean
public GammaTxnBoolean(GammaTxn tx, boolean value)
-
GammaTxnBoolean
public GammaTxnBoolean(GammaStm stm)
-
GammaTxnBoolean
public GammaTxnBoolean(GammaStm stm, boolean b)
-
-
Method Detail
-
get
public final boolean get()
Description copied from interface:TxnBooleanGets the value using the provided txn.- Specified by:
getin interfaceTxnBoolean- Returns:
- the current value.
- See Also:
TxnBoolean.atomicGet()
-
get
public final boolean get(Txn tx)
Description copied from interface:TxnBooleanGets the value using the provided txn.- Specified by:
getin interfaceTxnBoolean- Parameters:
tx- theTxnused for this operation.- Returns:
- the value stored in the ref.
-
get
public final boolean get(GammaTxn tx)
-
getAndLock
public final boolean getAndLock(LockMode lockMode)
Description copied from interface:TxnBooleanGets 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 interfaceTxnBoolean- Parameters:
lockMode- the LockMode applied.- Returns:
- the current value.
- See Also:
TxnBoolean.atomicGet()
-
getAndLock
public final boolean getAndLock(Txn tx, LockMode lockMode)
Description copied from interface:TxnBooleanGets the value using the provided txn and acquired the lock with the specified LockMode.- Specified by:
getAndLockin interfaceTxnBoolean- Parameters:
tx- theTxnused for this operation.lockMode- the LockMode used- Returns:
- the value stored in the ref.
-
set
public final boolean set(boolean value)
Description copied from interface:TxnBooleanSets the new value.This call lifts on the
Txnstored in theTxnThreadLocal.- Specified by:
setin interfaceTxnBoolean- Parameters:
value- the new value.- Returns:
- the new value.
-
set
public final boolean set(Txn tx, boolean value)
Description copied from interface:TxnBooleanSets the new value using the provided txn.- Specified by:
setin interfaceTxnBoolean- Parameters:
tx- theTxnused for this operation.value- the new value- Returns:
- the old value
-
set
public final boolean set(GammaTxn tx, boolean value)
-
setAndLock
public final boolean setAndLock(boolean value, LockMode lockMode)Description copied from interface:TxnBooleanSets the new value and applies the lock.This call lifts on the
Txnstored in theTxnThreadLocal.- Specified by:
setAndLockin interfaceTxnBoolean- Parameters:
value- the new value.lockMode- the used LockMode.- Returns:
- the new value.
-
setAndLock
public final boolean setAndLock(Txn tx, boolean value, LockMode lockMode)
Description copied from interface:TxnBooleanSets the new value using the provided txn.- Specified by:
setAndLockin interfaceTxnBoolean- Parameters:
tx- theTxnused for this operation.value- the new valuelockMode- the lockMode used.- Returns:
- the old value
-
getAndSet
public final boolean getAndSet(boolean value)
Description copied from interface:TxnBooleanSets the value the value and returns the new value.This call lifts on the
Txnstored in theTxnThreadLocal.- Specified by:
getAndSetin interfaceTxnBoolean- Parameters:
value- the new value.- Returns:
- the old value.
-
getAndSet
public final boolean getAndSet(Txn tx, boolean value)
Description copied from interface:TxnBooleanSets the value using the provided txn.- Specified by:
getAndSetin interfaceTxnBoolean- Parameters:
tx- theTxnused for this operation.value- the new value.- Returns:
- the old value.
-
getAndSetAndLock
public final boolean getAndSetAndLock(boolean value, LockMode lockMode)Description copied from interface:TxnBooleanSets 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 interfaceTxnBoolean- Parameters:
value- the new value.lockMode- the LockMode used.- Returns:
- the old value.
-
getAndSetAndLock
public final boolean getAndSetAndLock(Txn tx, boolean value, LockMode lockMode)
Description copied from interface:TxnBooleanSets the value and acquired the Lock with the provided LockMode.This call lifts on the
Txnstored in theTxnThreadLocal.- Specified by:
getAndSetAndLockin interfaceTxnBoolean- Parameters:
tx- theTxnused for this operation.value- the new value.lockMode- the LockMode used.- Returns:
- the old value.
-
getAndSetAndLock
public final boolean getAndSetAndLock(GammaTxn tx, boolean value, LockMode lockMode)
-
getAndSet
public final boolean getAndSet(GammaTxn tx, boolean value)
-
atomicGet
public final boolean atomicGet()
Description copied from interface:TxnBooleanAtomically 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 theTxnBoolean.atomicWeakGet().- Specified by:
atomicGetin interfaceTxnBoolean- Returns:
- the current value.
-
atomicWeakGet
public final boolean atomicWeakGet()
Description copied from interface:TxnBooleanAtomically 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 interfaceTxnBoolean- Returns:
- the value.
-
atomicSet
public final boolean atomicSet(boolean newValue)
Description copied from interface:TxnBooleanAtomically sets the value and returns the new value. This method doesn't care about any running txns.- Specified by:
atomicSetin interfaceTxnBoolean- Parameters:
newValue- the new value.- Returns:
- the new value.
-
atomicGetAndSet
public final boolean atomicGetAndSet(boolean newValue)
Description copied from interface:TxnBooleanAtomically sets the value and returns the previous value. This method doesn't care about any running txns.- Specified by:
atomicGetAndSetin interfaceTxnBoolean- Parameters:
newValue- the new value.- Returns:
- the old value.
-
commute
public final void commute(BooleanFunction function)
Description copied from interface:TxnBooleanApplies 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.- Specified by:
commutein interfaceTxnBoolean- Parameters:
function- the function to apply to this reference.
-
commute
public final void commute(Txn tx, BooleanFunction function)
Description copied from interface:TxnBooleanApplies 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.- Specified by:
commutein interfaceTxnBoolean- Parameters:
tx- theTxnused for this operation.function- the function to apply to this reference.
-
commute
public final void commute(GammaTxn tx, BooleanFunction function)
-
getAndAlter
public final boolean getAndAlter(BooleanFunction function)
Description copied from interface:TxnBooleanAlters 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 interfaceTxnBoolean- Parameters:
function- the function that alters the value stored in this Ref.- Returns:
- the old value.
-
getAndAlter
public final boolean getAndAlter(Txn tx, BooleanFunction function)
Description copied from interface:TxnBooleanAlters the value stored in this Ref using the function and returns the old value, using the provided txn.- Specified by:
getAndAlterin interfaceTxnBoolean- Parameters:
tx- theTxnused for this operation.function- the function that alters the value stored in this Ref.- Returns:
- the old value
-
getAndAlter
public final boolean getAndAlter(GammaTxn tx, BooleanFunction function)
-
alterAndGet
public final boolean alterAndGet(BooleanFunction function)
Description copied from interface:TxnBooleanAlters 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 interfaceTxnBoolean- Parameters:
function- the function that alters the value stored in this Ref.- Returns:
- the new value.
-
alterAndGet
public final boolean alterAndGet(Txn tx, BooleanFunction function)
Description copied from interface:TxnBooleanAlters the value stored in this Ref using the provided function and lifting on the provided txn.- Specified by:
alterAndGetin interfaceTxnBoolean- Parameters:
tx- theTxnused for this operation.function- the function that alters the value stored in this Ref.- Returns:
- the new value.
-
alterAndGet
public final boolean alterAndGet(GammaTxn tx, BooleanFunction function)
-
alter
public final boolean alter(GammaTxn tx, BooleanFunction function, boolean returnOld)
-
atomicAlterAndGet
public final boolean atomicAlterAndGet(BooleanFunction function)
Description copied from interface:TxnBooleanAtomically 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 interfaceTxnBoolean- Parameters:
function- the Function used- Returns:
- the new value.
-
atomicGetAndAlter
public final boolean atomicGetAndAlter(BooleanFunction function)
Description copied from interface:TxnBooleanAtomically 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 interfaceTxnBoolean- Parameters:
function- the Function used- Returns:
- the old value.
-
atomicAlter
private boolean atomicAlter(BooleanFunction function, boolean returnOld)
-
atomicCompareAndSet
public final boolean atomicCompareAndSet(boolean expectedValue, boolean newValue)Description copied from interface:TxnBooleanExecutes a compare and set atomically. This method doesn't care about any running txns.- Specified by:
atomicCompareAndSetin interfaceTxnBoolean- Parameters:
expectedValue- the expected value.newValue- the new value.- Returns:
- true if the compareAndSwap was a success, false otherwise.
-
await
public final void await(boolean value)
Description copied from interface:TxnBooleanAwaits 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.- Specified by:
awaitin interfaceTxnBoolean- Parameters:
value- the value to wait for.
-
await
public final void await(Txn tx, boolean value)
Description copied from interface:TxnBooleanAwaits 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.- Specified by:
awaitin interfaceTxnBoolean- Parameters:
tx- theTxnused for this operation.value- the value to wait for.
-
await
public final void await(GammaTxn tx, boolean value)
-
await
public final void await(BooleanPredicate predicate)
Description copied from interface:TxnBooleanAwaits 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.- Specified by:
awaitin interfaceTxnBoolean- Parameters:
predicate- the predicate to evaluate.
-
await
public final void await(Txn tx, BooleanPredicate predicate)
Description copied from interface:TxnBooleanAwaits 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.- Specified by:
awaitin interfaceTxnBoolean- Parameters:
tx- theTxnused for this operation.predicate- the predicate to evaluate.
-
await
public final void await(GammaTxn tx, BooleanPredicate predicate)
-
toDebugString
public final java.lang.String 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
public final java.lang.String toString()
Description copied from interface:TxnObjectReturns a String representation of the Object using theTxnon theTxnThreadLocal.
-
toString
public final java.lang.String toString(Txn tx)
Description copied from interface:TxnObjectReturns a String representation of the object using the providedTxn.
-
toString
public final java.lang.String toString(GammaTxn tx)
-
atomicToString
public final java.lang.String 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.
-
-