org.multiverse.stms.gamma.transactionalobjects

## Class BaseGammaTxnRef

- java.lang.Object
- - org.multiverse.stms.gamma.transactionalobjects.AbstractGammaObject
  - - org.multiverse.stms.gamma.transactionalobjects.BaseGammaTxnRef

All Implemented Interfaces:
  Lock, MultiverseConstants, GammaConstants, GammaObject

Direct Known Subclasses:
  GammaTxnBoolean, GammaTxnDouble, GammaTxnInteger, GammaTxnLong, GammaTxnRef

    public abstract class BaseGammaTxnRef
    extends AbstractGammaObject

### Field Summary

Fields
`long` `long_value`
`java.lang.Object` `ref_value`
`int` `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
`protected` `BaseGammaTxnRef(GammaStm stm, int type)`

### Method Summary

Methods
`void` `acquire(GammaTxn tx, LockMode lockMode)`
`void` `acquire(LockMode desiredLockMode)` Acquires a Lock with the provided LockMode.
`void` `acquire(Txn tx, LockMode desiredLockMode)` Acquires a Lock with the provided LockMode using the provided transaction.
`protected int` `arriveAndExclusiveLockOrBackoff()`
`boolean` `atomicCompareAndSetLong(long expectedValue, long newValue)`
`long` `atomicGetLong()`
`java.lang.Object` `atomicObjectGet()`
`long` `atomicSetLong(long newValue, boolean returnOld)`
`java.lang.Object` `atomicSetObject(java.lang.Object newValue, boolean returnOld)`
`Listeners` `commit(Tranlocal tranlocal, GammaObjectPool pool)`
`void` `ensure()`
`void` `ensure(GammaTxn tx)`
`void` `ensure(Txn self)`
`boolean` `flattenCommute(GammaTxn tx, Tranlocal tranlocal, int lockMode)`
`protected long` `getLong(GammaTxn tx, LockMode lockMode)`
`protected java.lang.Object` `getObject(GammaTxn tx, LockMode lockMode)`
`boolean` `hasReadConflict(Tranlocal tranlocal)`
`Listeners` `leanCommit(Tranlocal tranlocal)`
`boolean` `load(GammaTxn tx, Tranlocal tranlocal, int lockMode, int spinCount, boolean arriveNeeded)`
`void` `openForCommute(FatFixedLengthGammaTxn tx, Function function)`
`void` `openForCommute(FatMonoGammaTxn tx, Function function)`
`void` `openForCommute(FatVariableLengthGammaTxn tx, Function function)`
`void` `openForCommute(GammaTxn tx, Function function)`
`Tranlocal` `openForConstruction(FatFixedLengthGammaTxn tx)`
`Tranlocal` `openForConstruction(FatMonoGammaTxn tx)`
`Tranlocal` `openForConstruction(FatVariableLengthGammaTxn tx)`
`Tranlocal` `openForConstruction(GammaTxn tx)`
`Tranlocal` `openForRead(FatFixedLengthGammaTxn tx, int desiredLockMode)`
`Tranlocal` `openForRead(FatMonoGammaTxn tx, int lockMode)`
`Tranlocal` `openForRead(FatVariableLengthGammaTxn tx, int desiredLockMode)`
`Tranlocal` `openForRead(GammaTxn tx, int lockMode)`
`Tranlocal` `openForRead(LeanFixedLengthGammaTxn tx, int lockMode)`
`Tranlocal` `openForRead(LeanMonoGammaTxn tx, int lockMode)`
`Tranlocal` `openForWrite(FatFixedLengthGammaTxn tx, int lockMode)`
`Tranlocal` `openForWrite(FatMonoGammaTxn tx, int desiredLockMode)`
`Tranlocal` `openForWrite(FatVariableLengthGammaTxn tx, int lockMode)`
`Tranlocal` `openForWrite(GammaTxn tx, int lockMode)`
`Tranlocal` `openForWrite(LeanFixedLengthGammaTxn tx, int lockMode)`
`Tranlocal` `openForWrite(LeanMonoGammaTxn tx, int lockMode)`
`boolean` `prepare(GammaTxn tx, Tranlocal tranlocal)`
`int` `registerChangeListener(RetryLatch latch, Tranlocal tranlocal, GammaObjectPool pool, long listenerEra)`
`void` `releaseAfterFailure(Tranlocal tranlocal, GammaObjectPool pool)`
`void` `releaseAfterReading(Tranlocal tranlocal, GammaObjectPool pool)`
`void` `releaseAfterUpdate(Tranlocal tranlocal, GammaObjectPool pool)`
`protected long` `setLong(GammaTxn tx, LockMode lockMode, long newValue, boolean returnOld)`
`protected java.lang.Object` `setObject(GammaTxn tx, LockMode lockMode, java.lang.Object newValue, boolean returnOld)`
`boolean` `tryLockAndCheckConflict(GammaTxn tx, Tranlocal tranlocal, int spinCount, int desiredLockMode)` Tries to acquire a lock on a previous read/written tranlocal and checks for conflict.

### 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`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### type

    public final int type

#### long_value

    public volatile long long_value

#### ref_value

    public volatile java.lang.Object ref_value

### Constructor Detail

#### BaseGammaTxnRef

    protected BaseGammaTxnRef(GammaStm stm,
                   int type)

### Method Detail

#### flattenCommute

    public final boolean flattenCommute(GammaTxn tx,
                         Tranlocal tranlocal,
                         int lockMode)

#### commit

    public final Listeners commit(Tranlocal tranlocal,
                   GammaObjectPool pool)

#### leanCommit

    public final Listeners leanCommit(Tranlocal tranlocal)

#### prepare

    public final boolean prepare(GammaTxn tx,
                  Tranlocal tranlocal)

#### releaseAfterFailure

    public final void releaseAfterFailure(Tranlocal tranlocal,
                           GammaObjectPool pool)

#### releaseAfterUpdate

    public final void releaseAfterUpdate(Tranlocal tranlocal,
                          GammaObjectPool pool)

#### releaseAfterReading

    public final void releaseAfterReading(Tranlocal tranlocal,
                           GammaObjectPool pool)

#### load

    public final boolean load(GammaTxn tx,
               Tranlocal tranlocal,
               int lockMode,
               int spinCount,
               boolean arriveNeeded)

#### openForConstruction

    public final Tranlocal openForConstruction(GammaTxn tx)

#### openForConstruction

    public final Tranlocal openForConstruction(FatMonoGammaTxn tx)

#### openForConstruction

    public final Tranlocal openForConstruction(FatVariableLengthGammaTxn tx)

#### openForConstruction

    public final Tranlocal openForConstruction(FatFixedLengthGammaTxn tx)

#### openForRead

    public final Tranlocal openForRead(GammaTxn tx,
                        int lockMode)

#### openForRead

    public final Tranlocal openForRead(LeanMonoGammaTxn tx,
                        int lockMode)

#### openForRead

    public final Tranlocal openForRead(LeanFixedLengthGammaTxn tx,
                        int lockMode)

#### openForRead

    public final Tranlocal openForRead(FatMonoGammaTxn tx,
                        int lockMode)

#### openForRead

    public final Tranlocal openForRead(FatFixedLengthGammaTxn tx,
                        int desiredLockMode)

#### openForRead

    public final Tranlocal openForRead(FatVariableLengthGammaTxn tx,
                        int desiredLockMode)

#### openForWrite

    public final Tranlocal openForWrite(GammaTxn tx,
                         int lockMode)

#### openForWrite

    public final Tranlocal openForWrite(LeanMonoGammaTxn tx,
                         int lockMode)

#### openForWrite

    public final Tranlocal openForWrite(LeanFixedLengthGammaTxn tx,
                         int lockMode)

#### openForWrite

    public final Tranlocal openForWrite(FatMonoGammaTxn tx,
                         int desiredLockMode)

#### openForWrite

    public final Tranlocal openForWrite(FatFixedLengthGammaTxn tx,
                         int lockMode)

#### openForWrite

    public final Tranlocal openForWrite(FatVariableLengthGammaTxn tx,
                         int lockMode)

#### openForCommute

    public final void openForCommute(GammaTxn tx,
                      Function function)

#### openForCommute

    public final void openForCommute(FatMonoGammaTxn tx,
                      Function function)

#### openForCommute

    public final void openForCommute(FatFixedLengthGammaTxn tx,
                      Function function)

#### openForCommute

    public final void openForCommute(FatVariableLengthGammaTxn tx,
                      Function function)

#### ensure

    public final void ensure()

#### ensure

    public final void ensure(Txn self)

#### ensure

    public final void ensure(GammaTxn tx)

#### getLong

    protected final long getLong(GammaTxn tx,
               LockMode lockMode)

#### getObject

    protected final java.lang.Object getObject(GammaTxn tx,
                             LockMode lockMode)

#### setLong

    protected final long setLong(GammaTxn tx,
               LockMode lockMode,
               long newValue,
               boolean returnOld)

#### setObject

    protected final java.lang.Object setObject(GammaTxn tx,
                             LockMode lockMode,
                             java.lang.Object newValue,
                             boolean returnOld)

#### atomicGetLong

    public final long atomicGetLong()

#### atomicObjectGet

    public final java.lang.Object atomicObjectGet()

#### atomicSetLong

    public final long atomicSetLong(long newValue,
                     boolean returnOld)

#### atomicSetObject

    public final java.lang.Object atomicSetObject(java.lang.Object newValue,
                                   boolean returnOld)

#### atomicCompareAndSetLong

    public final boolean atomicCompareAndSetLong(long expectedValue,
                                  long newValue)

#### acquire

    public final void acquire(LockMode desiredLockMode)

Description copied from interface: `Lock`
Acquires a Lock with the provided LockMode. This call doesn't block if the Lock can't be upgraded, but throws a `ReadWriteConflict`. It could also be that the Lock is acquired, but the Txn sees that it isn't consistent anymore. In that case also a `ReadWriteConflict` is thrown.

This call makes use of the Txn stored in the `TxnThreadLocal`.

If the lockMode is lower than the LockMode the transaction already has on this Lock, the call is ignored.

Parameters:
  `desiredLockMode` - the desired lockMode.

#### acquire

    public final void acquire(Txn tx,
               LockMode desiredLockMode)

Description copied from interface: `Lock`
Acquires a Lock with the provided LockMode using the provided transaction. This call doesn't block if the Lock can't be upgraded but throws a `ReadWriteConflict`. It could also be that the Lock is acquired, but the Txn sees that it isn't consistent anymore. In that case also a `ReadWriteConflict` is thrown.

If the lockMode is lower than the LockMode the transaction already has on this Lock, the call is ignored.

Parameters:
  `tx` - the Txn used for this operation.
  `desiredLockMode` - the desired lockMode.

#### acquire

    public final void acquire(GammaTxn tx,
               LockMode lockMode)

#### tryLockAndCheckConflict

    public final boolean tryLockAndCheckConflict(GammaTxn tx,
                                  Tranlocal tranlocal,
                                  int spinCount,
                                  int desiredLockMode)

Tries to acquire a lock on a previous read/written tranlocal and checks for conflict.

If the lockMode == LOCKMODE_NONE, this call is ignored.

The call to this method can safely made if the current lock level is higher the the desired LockMode.

If the can't be acquired, no changes are made on the tranlocal.

Parameters:
  `tx` -
  `tranlocal` - the tranlocal
  `spinCount` - the maximum number of times to spin
  `desiredLockMode` -
Returns:
  true if the lock was acquired successfully and there was no conflict.

#### registerChangeListener

    public final int registerChangeListener(RetryLatch latch,
                             Tranlocal tranlocal,
                             GammaObjectPool pool,
                             long listenerEra)

#### hasReadConflict

    public final boolean hasReadConflict(Tranlocal tranlocal)

#### arriveAndExclusiveLockOrBackoff

    protected final int arriveAndExclusiveLockOrBackoff()