Interface DAtomicReference<V>

  • All Superinterfaces:
    DType

    public interface DAtomicReference<V>
    extends DType
    A distributed and highly-available implementation of AtomicReferences.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      V accumulateAndGet​(V x, java.util.function.BinaryOperator<V> accumulatorFunction)
      Atomically updates the current value with the results of applying the given function to the current and given values, returning the updated value.
      boolean compareAndSet​(V expect, V update)
      Atomically sets the value to the given updated value if the current value == the expected value.
      V get()
      Gets the current value.
      V getAndAccumulate​(V x, java.util.function.BinaryOperator<V> accumulatorFunction)
      Atomically updates the current value with the results of applying the given function to the current and given values, returning the previous value.
      V getAndSet​(V newValue)
      Atomically sets to the given value and returns the old value.
      V getAndUpdate​(java.util.function.UnaryOperator<V> updateFunction)
      Atomically updates the current value with the results of applying the given function, returning the previous value.
      void set​(V newValue)
      Sets to the given value.
      V updateAndGet​(java.util.function.UnaryOperator<V> updateFunction)
      Atomically updates the current value with the results of applying the given function, returning the updated value.
    • Method Detail

      • accumulateAndGet

        V accumulateAndGet​(V x,
                           java.util.function.BinaryOperator<V> accumulatorFunction)
        Atomically updates the current value with the results of applying the given function to the current and given values, returning the updated value.

        Note that the provided function will also need to be declared as Serializable:

           ref.accumulateAndGet(1L, (Serializable & BinaryOperator<Long>) Long::sum);
         
        Parameters:
        x - the update value
        accumulatorFunction - a side-effect-free function of two arguments
        Returns:
        the updated value
      • compareAndSet

        boolean compareAndSet​(V expect,
                              V update)
        Atomically sets the value to the given updated value if the current value == the expected value.
        Parameters:
        expect - the expected value
        update - the new value
        Returns:
        true if successful
      • get

        V get()
        Gets the current value.
        Returns:
        the current value
      • getAndAccumulate

        V getAndAccumulate​(V x,
                           java.util.function.BinaryOperator<V> accumulatorFunction)
        Atomically updates the current value with the results of applying the given function to the current and given values, returning the previous value.

        Note that the provided function will also need to be declared as Serializable:

           ref.getAndAccumulate(1L, (Serializable & BinaryOperator<Long>) Long::sum);
         
        Parameters:
        x - the update value
        accumulatorFunction - a side-effect-free function of two arguments
        Returns:
        the previous value
      • getAndUpdate

        V getAndUpdate​(java.util.function.UnaryOperator<V> updateFunction)
        Atomically updates the current value with the results of applying the given function, returning the previous value.

        Note that the provided function will also need to be declared as Serializable:

           ref.getAndUpdate((Serializable & UnaryOperator<Long>) x -> x * 7)
         
        Parameters:
        updateFunction - a side-effect-free function
        Returns:
        the previous value
      • getAndSet

        V getAndSet​(V newValue)
        Atomically sets to the given value and returns the old value.
        Parameters:
        newValue - the value to set
        Returns:
        the previous value
      • set

        void set​(V newValue)
        Sets to the given value.
        Parameters:
        newValue - the value to set
      • updateAndGet

        V updateAndGet​(java.util.function.UnaryOperator<V> updateFunction)
        Atomically updates the current value with the results of applying the given function, returning the updated value.

        Note that the provided function will also need to be declared as Serializable:

           ref.updateAndGet((Serializable & UnaryOperator<Long>) x -> x * 7)
         
        Parameters:
        updateFunction - a side-effect-free function
        Returns:
        the updated value