Interface AsyncAtomicValue<V>

Type Parameters:
V - value type
All Superinterfaces:
AsyncPrimitive, DistributedPrimitive

public interface AsyncAtomicValue<V> extends AsyncPrimitive
Distributed version of java.util.concurrent.atomic.AtomicReference.

All methods of this interface return a future immediately after a successful invocation. The operation itself is executed asynchronous and the returned future will be completed when the operation finishes.

  • Method Details

    • get

      Gets the current value.
      Returns:
      current value
    • set

      Sets to the given value.
      Parameters:
      value - new value
      Returns:
      previous versioned value
    • set

      CompletableFuture<Versioned<V>> set(V value, long version)
      Sets to the given value.
      Parameters:
      value - new value
      Returns:
      previous versioned value
    • listen

      Registers the specified listener to be notified whenever the atomic value is updated.
      Parameters:
      listener - listener to notify about events
      Returns:
      CompletableFuture that will be completed when the operation finishes
    • listen

      Registers the specified listener to be notified whenever the atomic value is updated.
      Parameters:
      listener - listener to notify about events
      Returns:
      CompletableFuture that will be completed when the operation finishes
    • sync

      default AtomicValue<V> sync()
      Description copied from interface: AsyncPrimitive
      Returns a synchronous wrapper around the asynchronous primitive.
      Specified by:
      sync in interface AsyncPrimitive
      Returns:
      the synchronous primitive
    • sync

      AtomicValue<V> sync(Duration operationTimeout)
      Description copied from interface: AsyncPrimitive
      Returns a synchronous wrapper around the asynchronous primitive.
      Specified by:
      sync in interface AsyncPrimitive
      Parameters:
      operationTimeout - the synchronous operation timeout
      Returns:
      the synchronous primitive