Class LocalAtomicBoolean

  • All Implemented Interfaces:
    AtomicBoolean

    public class LocalAtomicBoolean
    extends Object
    implements AtomicBoolean
    Local implementation of AtomicBoolean interface, that simply wraps java.util.concurrent.atomic.AtomicBoolean instance.
    Since:
    21.12
    Author:
    Aleks Seovic 2020.12.07
    • Constructor Detail

      • LocalAtomicBoolean

        protected LocalAtomicBoolean​(boolean fValue)
        Construct LocalAtomicBoolean instance.
        Parameters:
        fValue - initial value
      • LocalAtomicBoolean

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

      • get

        public boolean get()
        Description copied from interface: AtomicBoolean
        Returns the current value.
        Specified by:
        get in interface AtomicBoolean
        Returns:
        the current value
      • set

        public void set​(boolean fNewValue)
        Description copied from interface: AtomicBoolean
        Sets the value to newValue.
        Specified by:
        set in interface AtomicBoolean
        Parameters:
        fNewValue - the new value
      • getAndSet

        public boolean getAndSet​(boolean fNewValue)
        Description copied from interface: AtomicBoolean
        Atomically sets the value to newValue and returns the old value.
        Specified by:
        getAndSet in interface AtomicBoolean
        Parameters:
        fNewValue - the new value
        Returns:
        the previous value
      • compareAndSet

        public boolean compareAndSet​(boolean fExpectedValue,
                                     boolean fNewValue)
        Description copied from interface: AtomicBoolean
        Atomically sets the value to newValue if the current value == expectedValue.
        Specified by:
        compareAndSet in interface AtomicBoolean
        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 boolean compareAndExchange​(boolean fExpectedValue,
                                          boolean fNewValue)
        Description copied from interface: AtomicBoolean
        Atomically sets the value to newValue if the current value, referred to as the witness value, == expectedValue.
        Specified by:
        compareAndExchange in interface AtomicBoolean
        Parameters:
        fExpectedValue - the expected value
        fNewValue - the new value
        Returns:
        the witness value, which will be the same as the expected value if successful