Class AsyncLocalAtomicBoolean

  • All Implemented Interfaces:
    AsyncAtomicBoolean

    public class AsyncLocalAtomicBoolean
    extends Object
    implements AsyncAtomicBoolean
    Local implementation of AsyncAtomicBoolean interface, that simply wraps java.util.concurrent.atomic.AtomicBoolean instance and returns an already completed future from each method.
    Author:
    Aleks Seovic 2020.12.07
    • Field Detail

      • f_fValue

        protected final AtomicBoolean f_fValue
        Wrapped atomic boolean value.
    • Constructor Detail

      • AsyncLocalAtomicBoolean

        protected AsyncLocalAtomicBoolean​(AtomicBoolean value)
        Construct LocalAtomicBoolean instance.
        Parameters:
        value - wrapped value
    • Method Detail

      • compareAndSet

        public CompletableFuture<Boolean> compareAndSet​(boolean fExpectedValue,
                                                        boolean fNewValue)
        Description copied from interface: AsyncAtomicBoolean
        Atomically sets the value to newValue if the current value == expectedValue.
        Specified by:
        compareAndSet in interface AsyncAtomicBoolean
        Parameters:
        fExpectedValue - the expected value
        fNewValue - the new value
        Returns:
        true if successful. False return indicates that the actual value was not equal to the expected value.
      • compareAndExchange

        public CompletableFuture<Boolean> compareAndExchange​(boolean fExpectedValue,
                                                             boolean fNewValue)
        Description copied from interface: AsyncAtomicBoolean
        Atomically sets the value to newValue if the current value, referred to as the witness value, == expectedValue.
        Specified by:
        compareAndExchange in interface AsyncAtomicBoolean
        Parameters:
        fExpectedValue - the expected value
        fNewValue - the new value
        Returns:
        the witness value, which will be the same as the expected value if successful
      • toString

        public String toString()
        Returns the String representation of the current value.
        Overrides:
        toString in class Object
        Returns:
        the String representation of the current value