Interface AtomicValue<V>

    • Method Detail

      • compareAndSet

        boolean compareAndSet​(V expect,
                              V update)
        Atomically sets the value to the given updated value if the current value is equal to the expected value.

        IMPORTANT: Equality is based on the equality of the serialized byte[] representations.

        Parameters:
        expect - the expected value
        update - the new value
        Returns:
        true if successful. false return indicates that the actual value was not equal to the expected value.
      • get

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

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

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

        void addListener​(AtomicValueEventListener<V> listener)
        Registers the specified listener to be notified whenever the atomic value is updated.
        Parameters:
        listener - listener to notify about events
      • removeListener

        void removeListener​(AtomicValueEventListener<V> listener)
        Unregisters the specified listener such that it will no longer receive atomic value update notifications.
        Parameters:
        listener - listener to unregister