Class LoomAtomicReference<T>

java.lang.Object
com.loomcache.client.LoomAtomicReference<T>
Type Parameters:
T - the reference value type

public final class LoomAtomicReference<T> extends Object
Client-side distributed atomic reference proxy backed by the CP subsystem.

Operations are linearizable when used against a cluster: mutations are committed through Raft and reads are served through the server's linearizable-read path.

Since:
1.4
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the reference by setting it to null.
    boolean
    compareAndSet(@Nullable T expectedValue, @Nullable T newValue)
    Atomically updates the reference when the current value equals the expected value.
    @Nullable T
    get()
    Gets the current reference value.
    boolean
    Returns whether the reference currently holds null.
    void
    set(@Nullable T value)
    Sets the current reference value.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • get

      public @Nullable T get()
      Gets the current reference value.
      Returns:
      the current value, or null when the reference is clear
    • set

      public void set(@Nullable T value)
      Sets the current reference value.
      Parameters:
      value - the new value, or null to clear
    • compareAndSet

      public boolean compareAndSet(@Nullable T expectedValue, @Nullable T newValue)
      Atomically updates the reference when the current value equals the expected value.
      Parameters:
      expectedValue - the expected current value
      newValue - the new value to store on success
      Returns:
      true when the value was updated
    • clear

      public void clear()
      Clears the reference by setting it to null.
    • isNull

      public boolean isNull()
      Returns whether the reference currently holds null.