Interface DAtomicReference<V>

All Superinterfaces:
DType

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

    Modifier and Type
    Method
    Description
    accumulateAndGet(V x, 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.
    get()
    Gets the current value.
    getAndAccumulate(V x, 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.
    getAndSet(V newValue)
    Atomically sets to the given value and returns the old value.
    getAndUpdate(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.
    updateAndGet(UnaryOperator<V> updateFunction)
    Atomically updates the current value with the results of applying the given function, returning the updated value.

    Methods inherited from interface com.vmware.gemfire.distributedtypes.DType

    destroy, getName
  • Method Details

    • accumulateAndGet

      V accumulateAndGet(V x, 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, 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(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(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