Class DefaultAtomicValue<V>

    • Constructor Detail

      • DefaultAtomicValue

        public DefaultAtomicValue​(AsyncAtomicValue<V> asyncValue,
                                  long operationTimeoutMillis)
    • Method Detail

      • compareAndSet

        public boolean compareAndSet​(V expect,
                                     V update)
        Description copied from interface: AtomicValue
        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.

        Specified by:
        compareAndSet in interface AtomicValue<V>
        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

        public V get()
        Description copied from interface: AtomicValue
        Gets the current value.
        Specified by:
        get in interface AtomicValue<V>
        Returns:
        current value
      • getAndSet

        public V getAndSet​(V value)
        Description copied from interface: AtomicValue
        Atomically sets to the given value and returns the old value.
        Specified by:
        getAndSet in interface AtomicValue<V>
        Parameters:
        value - the new value
        Returns:
        previous value
      • set

        public void set​(V value)
        Description copied from interface: AtomicValue
        Sets to the given value.
        Specified by:
        set in interface AtomicValue<V>
        Parameters:
        value - new value
      • addListener

        public void addListener​(AtomicValueEventListener<V> listener)
        Description copied from interface: AtomicValue
        Registers the specified listener to be notified whenever the atomic value is updated.
        Specified by:
        addListener in interface AtomicValue<V>
        Parameters:
        listener - listener to notify about events
      • removeListener

        public void removeListener​(AtomicValueEventListener<V> listener)
        Description copied from interface: AtomicValue
        Unregisters the specified listener such that it will no longer receive atomic value update notifications.
        Specified by:
        removeListener in interface AtomicValue<V>
        Parameters:
        listener - listener to unregister