Interface TxnInteger

  • All Superinterfaces:
    TxnObject
    All Known Implementing Classes:
    GammaTxnInteger

    public interface TxnInteger
    extends TxnObject
    A Transactional Reference comparable to the Clojure Ref. If a method is prefixed with atomic, the call will always run under its own txn, no matter if there already is a txn available (so the propagation level is PropagationLevel.RequiresNew). For the other methods, always an txn needs to be available, else you will get the TxnMandatoryException.

    ControlFlowError

    All non atomic methods are able to throw a (subclass) of the ControlFlowError. This error should not be caught, it is task of the TxnExecutor to deal with.

    TransactionExecutionException

    Most of the methods can throw a TxnExecutionException. This exception can be caught, but in most cases you want to figure out what the cause is (e.g. because there are too many retries) and solve that problem.

    Threadsafe

    All methods are threadsafe.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int alterAndGet​(IntFunction function)
      Alters the value stored in this Ref using the provided function and returns the result.
      int alterAndGet​(Txn txn, 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.
      int atomicWeakGet()
      Atomically gets the value without providing any ordering guarantees.
      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 txn, int value)
      Awaits for the reference to become the given value.
      void await​(Txn txn, IntPredicate predicate)
      Awaits until the predicate holds using the provided txn.
      void commute​(IntFunction function)
      Applies the function on the ref in a commuting manner.
      void commute​(Txn txn, 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 txn)
      Decrements the value by one using the provided txn.
      void decrement​(Txn txn, int amount)
      Decrements the value by the given amount using the provided txn.
      int get()
      Gets the value using the provided txn.
      int get​(Txn txn)
      Gets the value using the provided txn.
      int getAndAlter​(IntFunction function)
      Alters the value stored in this Ref using the provided function amd returns the old value.
      int getAndAlter​(Txn txn, IntFunction function)
      Alters the value stored in this Ref using the function and returns the old value, using the provided txn.
      int getAndIncrement​(int amount)
      Increments the value and returns the old value.
      int getAndIncrement​(Txn txn, int amount)
      Increments the value and returns the old value using the provided txn.
      int getAndLock​(LockMode lockMode)
      Gets the value and applies the lock.
      int getAndLock​(Txn txn, LockMode lockMode)
      Gets the value using the provided txn and acquired the lock with the specified LockMode.
      int getAndSet​(int value)
      Sets the value the value and returns the new value.
      int getAndSet​(Txn txn, 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 txn, int value, LockMode lockMode)
      Sets the value and acquired the Lock with the provided LockMode.
      void increment()
      Increments the value by one.
      void increment​(int amount)
      Increments the value by the given amount.
      void increment​(Txn txn)
      Increments the value by one using the provided txn.
      void increment​(Txn txn, int amount)
      Increments the value by the given amount using the provided txn.
      int incrementAndGet​(int amount)
      Increments and gets the new value.
      int incrementAndGet​(Txn txn, int amount)
      Increments and gets the new value using the provided txn.
      int set​(int value)
      Sets the new value.
      int set​(Txn txn, int value)
      Sets the new value using the provided txn.
      int setAndLock​(int value, LockMode lockMode)
      Sets the new value and applies the lock.
      int setAndLock​(Txn txn, int value, LockMode lockMode)
      Sets the new value using the provided txn.
    • Method Detail

      • get

        int get()
        Gets the value using the provided txn.
        Returns:
        the current value.
        Throws:
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
        See Also:
        atomicGet()
      • getAndLock

        int getAndLock​(LockMode lockMode)
        Gets 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 Txn stored in the TxnThreadLocal.

        Parameters:
        lockMode - the LockMode applied.
        Returns:
        the current value.
        Throws:
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
        See Also:
        atomicGet()
      • get

        int get​(Txn txn)
        Gets the value using the provided txn.
        Parameters:
        txn - the Txn used for this operation.
        Returns:
        the value stored in the ref.
        Throws:
        java.lang.NullPointerException - if txn is null.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • getAndLock

        int getAndLock​(Txn txn,
                       LockMode lockMode)
        Gets the value using the provided txn and acquired the lock with the specified LockMode.
        Parameters:
        txn - the Txn used for this operation.
        lockMode - the LockMode used
        Returns:
        the value stored in the ref.
        Throws:
        java.lang.NullPointerException - if txn is null or if lockMode is null. If LockMode is null and a running txn is available it will be aborted.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • set

        int set​(int value)
        Sets the new value.

        This call lifts on the Txn stored in the TxnThreadLocal.

        Parameters:
        value - the new value.
        Returns:
        the new value.
        Throws:
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • setAndLock

        int setAndLock​(int value,
                       LockMode lockMode)
        Sets the new value and applies the lock.

        This call lifts on the Txn stored in the TxnThreadLocal.

        Parameters:
        value - the new value.
        lockMode - the used LockMode.
        Returns:
        the new value.
        Throws:
        java.lang.NullPointerException - if lockMode is null (if the txn is alive, it will also be aborted.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • set

        int set​(Txn txn,
                int value)
        Sets the new value using the provided txn.
        Parameters:
        txn - the Txn used for this operation.
        value - the new value
        Returns:
        the old value
        Throws:
        java.lang.NullPointerException - if txn is null.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • setAndLock

        int setAndLock​(Txn txn,
                       int value,
                       LockMode lockMode)
        Sets the new value using the provided txn.
        Parameters:
        txn - the Txn used for this operation.
        value - the new value
        lockMode - the lockMode used.
        Returns:
        the old value
        Throws:
        java.lang.NullPointerException - if txn is null or lockMode is null. If the lockMode is null and the txn is alive, it will be aborted.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • getAndSet

        int getAndSet​(int value)
        Sets the value the value and returns the new value.

        This call lifts on the Txn stored in the TxnThreadLocal.

        Parameters:
        value - the new value.
        Returns:
        the old value.
        Throws:
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • getAndSetAndLock

        int getAndSetAndLock​(int value,
                             LockMode lockMode)
        Sets the value, acquired the Lock with the specified Lockmode and returns the previous value.

        This call lifts on the Txn stored in the TxnThreadLocal.

        Parameters:
        value - the new value.
        lockMode - the LockMode used.
        Returns:
        the old value.
        Throws:
        java.lang.NullPointerException - if LockMode is null. If a running txn is available, it will be aborted.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • getAndSet

        int getAndSet​(Txn txn,
                      int value)
        Sets the value using the provided txn.
        Parameters:
        value - the new value.
        txn - the Txn used for this operation.
        Returns:
        the old value.
        Throws:
        java.lang.NullPointerException - if txn is null.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • getAndSetAndLock

        int getAndSetAndLock​(Txn txn,
                             int value,
                             LockMode lockMode)
        Sets the value and acquired the Lock with the provided LockMode.

        This call lifts on the Txn stored in the TxnThreadLocal.

        Parameters:
        value - the new value.
        txn - the Txn used for this operation.
        lockMode - the LockMode used.
        Returns:
        the old value.
        Throws:
        java.lang.NullPointerException - if txn or LockMode is null. If the txn is running, and the LockMode is null, it will be aborted.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • atomicGet

        int atomicGet()
        Atomically 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 the atomicWeakGet().
        Returns:
        the current value.
        Throws:
        TxnExecutionException
      • atomicWeakGet

        int atomicWeakGet()
        Atomically 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.

        Returns:
        the value.
      • atomicSet

        int atomicSet​(int newValue)
        Atomically sets the value and returns the new value. This method doesn't care about any running txns.
        Parameters:
        newValue - the new value.
        Returns:
        the new value.
        Throws:
        TxnExecutionException
      • atomicGetAndSet

        int atomicGetAndSet​(int newValue)
        Atomically sets the value and returns the previous value. This method doesn't care about any running txns.
        Parameters:
        newValue - the new value.
        Returns:
        the old value.
        Throws:
        TxnExecutionException
      • commute

        void commute​(IntFunction function)
        Applies 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 Txn stored in the TxnThreadLocal.

        Parameters:
        function - the function to apply to this reference.
        Throws:
        java.lang.NullPointerException - if function is null.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • commute

        void commute​(Txn txn,
                     IntFunction function)
        Applies 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 Txn stored in the TxnThreadLocal.

        Parameters:
        txn - the Txn used for this operation.
        function - the function to apply to this reference.
        Throws:
        java.lang.NullPointerException - if function is null. If there is an active txn, it will be aborted.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • atomicAlterAndGet

        int atomicAlterAndGet​(IntFunction function)
        Atomically applies the function to the current value in this ref and returns the new value. This method doesn't care about any running txns.
        Parameters:
        function - the Function used
        Returns:
        the new value.
        Throws:
        java.lang.NullPointerException - if function is null.
      • alterAndGet

        int alterAndGet​(IntFunction function)
        Alters the value stored in this Ref using the provided function and returns the result.

        This call lifts on the Txn stored in the TxnThreadLocal.

        Parameters:
        function - the function that alters the value stored in this Ref.
        Returns:
        the new value.
        Throws:
        java.lang.NullPointerException - if function is null. The Txn will also be aborted.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • alterAndGet

        int alterAndGet​(Txn txn,
                        IntFunction function)
        Alters the value stored in this Ref using the provided function and lifting on the provided txn.
        Parameters:
        function - the function that alters the value stored in this Ref.
        txn - the Txn used for this operation.
        Returns:
        the new value.
        Throws:
        java.lang.NullPointerException - if function or txn is null.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • atomicGetAndAlter

        int atomicGetAndAlter​(IntFunction function)
        Atomically 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.
        Parameters:
        function - the Function used
        Returns:
        the old value.
        Throws:
        java.lang.NullPointerException - if function is null.
        TxnExecutionException
      • getAndAlter

        int getAndAlter​(IntFunction function)
        Alters the value stored in this Ref using the provided function amd returns the old value.

        This call lifts on the Txn stored in the TxnThreadLocal.

        Parameters:
        function - the function that alters the value stored in this Ref.
        Returns:
        the old value.
        Throws:
        java.lang.NullPointerException - if function is null. The txn will be aborted as well.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • getAndAlter

        int getAndAlter​(Txn txn,
                        IntFunction function)
        Alters the value stored in this Ref using the function and returns the old value, using the provided txn.
        Parameters:
        function - the function that alters the value stored in this Ref.
        txn - the Txn used for this operation.
        Returns:
        the old value
        Throws:
        java.lang.NullPointerException - if function or txn is null. The txn will be aborted as well.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • atomicCompareAndSet

        boolean atomicCompareAndSet​(int expectedValue,
                                    int newValue)
        Executes a compare and set atomically. This method doesn't care about any running txns.
        Parameters:
        expectedValue - the expected value.
        newValue - the new value.
        Returns:
        true if the compareAndSwap was a success, false otherwise.
        Throws:
        TxnExecutionException
      • atomicGetAndIncrement

        int atomicGetAndIncrement​(int amount)
        Atomically increments the value and returns the old value. This method doesn't care about any running txns.
        Parameters:
        amount - the amount to increase with.
        Returns:
        the old value.
        Throws:
        TxnExecutionException
      • getAndIncrement

        int getAndIncrement​(int amount)
        Increments the value and returns the old value.

        This call lifts on the Txn stored in the TxnThreadLocal.

        Parameters:
        amount - the amount to increment with.
        Returns:
        the old value.
        Throws:
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • getAndIncrement

        int getAndIncrement​(Txn txn,
                            int amount)
        Increments the value and returns the old value using the provided txn.
        Parameters:
        txn - the Txn used for this operation.
        amount - the amount to increment with.
        Returns:
        the old value.
        Throws:
        java.lang.NullPointerException - if txn is null.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • atomicIncrementAndGet

        int atomicIncrementAndGet​(int amount)
        Atomically increments the value and returns the old value. This method doesn't care about any running txns.
        Parameters:
        amount - the amount to increment with.
        Returns:
        the new value.
        Throws:
        TxnExecutionException
      • incrementAndGet

        int incrementAndGet​(int amount)
        Increments and gets the new value.

        This call lifts on the Txn stored in the TxnThreadLocal.

        Parameters:
        amount - the amount to increment with.
        Returns:
        the new value.
        Throws:
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • incrementAndGet

        int incrementAndGet​(Txn txn,
                            int amount)
        Increments and gets the new value using the provided txn.
        Parameters:
        txn - the Txn used for this operation.
        amount - the amount to increment with.
        Returns:
        the new value.
        Throws:
        java.lang.NullPointerException - if txn is null.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • increment

        void increment()
        Increments 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 Txn stored in the TxnThreadLocal.

        Throws:
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • increment

        void increment​(Txn txn)
        Increments 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.

        Parameters:
        txn - the Txn used for this operation.
        Throws:
        java.lang.NullPointerException - if txn is null.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • increment

        void increment​(int amount)
        Increments 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 Txn stored in the TxnThreadLocal.

        Parameters:
        amount - the amount to increase with
        Throws:
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.ControlFlowError
      • increment

        void increment​(Txn txn,
                       int amount)
        Increments 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.

        Parameters:
        txn - the Txn used for this operation.
        amount - the amount to increment with
        Throws:
        java.lang.NullPointerException - if txn is null.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • decrement

        void decrement()
        Decrements 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 Txn stored in the TxnThreadLocal.

        Throws:
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • decrement

        void decrement​(Txn txn)
        Decrements 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.

        Parameters:
        txn - the Txn used for this operation.
        Throws:
        java.lang.NullPointerException - if txn is null.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • decrement

        void decrement​(int amount)
        Decrements 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 Txn stored in the TxnThreadLocal.

        Parameters:
        amount - the amount to decrement with
        Throws:
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • decrement

        void decrement​(Txn txn,
                       int amount)
        Decrements 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.

        Parameters:
        txn - the Txn used for this operation.
        amount - the amount to decrement with
        Throws:
        java.lang.NullPointerException - if txn is null.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • await

        void await​(int value)
        Awaits 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 Txn stored in the TxnThreadLocal.

        Parameters:
        value - the value to wait for.
        Throws:
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • await

        void await​(Txn txn,
                   int value)
        Awaits 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.
        Parameters:
        txn - the Txn used for this operation.
        value - the value to wait for.
        Throws:
        java.lang.NullPointerException - if txn is null.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • await

        void await​(IntPredicate predicate)
        Awaits 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 Txn stored in the TxnThreadLocal.

        Parameters:
        predicate - the predicate to evaluate.
        Throws:
        java.lang.NullPointerException - if predicate is null. When there is a non dead txn, it will be aborted.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.
      • await

        void await​(Txn txn,
                   IntPredicate predicate)
        Awaits 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.
        Parameters:
        txn - the Txn used for this operation.
        predicate - the predicate to evaluate.
        Throws:
        java.lang.NullPointerException - if predicate is null or txn is null. When there is a non dead txn, it will be aborted.
        TxnExecutionException - if something failed while using the txn. The txn is guaranteed to have been aborted.
        ControlFlowError - if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn is guaranteed to have been aborted.