Interface TxnConfig

All Known Implementing Classes:
GammaTxnConfig

public interface TxnConfig
Contains the transaction configuration used by a Txn. In the beginning this was all placed in the Txn, adding a lot of 'informational' methods to the transaction and therefor complicating its usage. So all the configurational properties of the transaction are contained in this structure.

The same TxnConfig is used for multiple transactions. Each TxnFactory has just a single configuration and all Transactions created by that TxnFactory, share that configuration.

  • Method Details

    • getStm

      Stm getStm()
      Returns the Stm that creates transactions based on this configuration.
      Returns:
      the stm.
    • isControlFlowErrorsReused

      boolean isControlFlowErrorsReused()
      Checks if the ControlFlowError is cached or a new one is used.

      Exception creation can be very expensive, so by default the ControlFlowError is reused, but this can be problematic when debugging.

      Returns:
      true if the ControlFlowError is reused.
      See Also:
    • getIsolationLevel

      IsolationLevel getIsolationLevel()
      Gets the IsolationLevel used. With the IsolationLevel you have control on the isolated behavior between transactions.
      Returns:
      the IsolationLevel.
      See Also:
    • getTimeoutNs

      long getTimeoutNs()
      Returns the total timeout in nanoseconds. Long.MAX_VALUE indicates that there is no timeout.
      Returns:
      the total remaining timeout.
      See Also:
    • getPropagationLevel

      PropagationLevel getPropagationLevel()
      Returns the PropagationLevel used. With the PropagationLevel you have control on how the transaction is dealing with nesting of transactions.
      Returns:
      the PropagationLevel used.
      See Also:
    • getTraceLevel

      TraceLevel getTraceLevel()
      Returns the TraceLevel. With the TraceLevel you have control on the logging.
      Returns:
      the TraceLevel.
      See Also:
    • getBackoffPolicy

      BackoffPolicy getBackoffPolicy()
      Returns the BackoffPolicy used by the Stm when a transaction conflicts with another transaction.
      Returns:
      the BackoffPolicy used.
      See Also:
    • isSpeculative

      boolean isSpeculative()
      Checks if speculative configuration is enabled. When enabled the STM is able to select better performing/scalable implementations at the cost of some SpeculativeConfigurationError. This will be caught by the TxnExecutor and the transaction will be retried, so in most cases this is not something to worry about, but it can be confusing in the beginning because of unexpected failures in the execution of transactions.
      Returns:
      true if speculative configuration is enabled.
      See Also:
    • getFamilyName

      String getFamilyName()
      Returns the family name of this Txn. Every transaction in principle should have a family name. This information can be used for debugging/logging purposes but also other techniques that rely to know something about similar types of transactions like profiling.
      Returns:
      the familyName. The returned value can be null.
      See Also:
    • isReadonly

      boolean isReadonly()
      Checks if this Txn is readonly. With a readonly transaction you can prevent any updates or new objects being created.
      Returns:
      true if readonly, false otherwise.
      See Also:
    • getSpinCount

      int getSpinCount()
      Returns the maximum number of times the transaction is allowed to spin on a read to become readable (perhaps it is locked).
      Returns:
      the maximum number of spins
      See Also:
    • getReadLockMode

      LockMode getReadLockMode()
      Gets the current LockMode for all reads.
      Returns:
      the current LockMode for all reads.
      See Also:
    • getWriteLockMode

      LockMode getWriteLockMode()
      Gets the current LockMode for all writes.
      Returns:
      the current LockMode for all writes.
      See Also:
    • isDirtyCheckEnabled

      boolean isDirtyCheckEnabled()
      Checks if dirty check is enabled on writes when a transaction commits. Turning of saves time, but forces writes that cause no change.
      Returns:
      true of dirty check is enabled.
      See Also:
    • isReadTrackingEnabled

      boolean isReadTrackingEnabled()
      Checks if this transaction does automatic read tracking. Read tracking is needed for blocking transactions, but also for writeskew detection. Disadvantage of read tracking is that it is more expensive because the reads not to be registered on some datastructure so that they are tracked.
      Returns:
      true if the transaction does automatic read tracking, false otherwise.
      See Also:
    • isBlockingAllowed

      boolean isBlockingAllowed()
      If an explicit retry (so a blocking transaction) is allowed. With this property one can prevent that a Txn is able to block waiting for some change.
      Returns:
      true if explicit retry is allowed, false otherwise.
      See Also:
    • isInterruptible

      boolean isInterruptible()
      Checks if the Txn can be interrupted if it is blocking.
      Returns:
      true if the Txn can be interrupted if it is blocking, false otherwise.
      See Also:
    • getPermanentListeners

      List<TxnListener> getPermanentListeners()
      Returns an unmodifiable list containing all permanent TxnListener.
      Returns:
      unmodifiable List containing all permanent TxnListeners.
      See Also:
    • getMaxRetries

      int getMaxRetries()
      Returns the maximum number of times this Txn be retried before failing. The returned value will always be equal or larger than 0. If the value is getAndSet high and you are encountering a lot of TooManyRetryExceptions it could be that the objects are just not concurrent enough.
      Returns:
      the maxRetries.
      See Also: