Interface AtomicBoolean

  • All Known Implementing Classes:
    LocalAtomicBoolean, RemoteAtomicBoolean

    public interface AtomicBoolean
    A boolean value that may be updated atomically.

    An AtomicBoolean is used in applications such as atomically updated flags, and cannot be used as a replacement for a Boolean.

    Since:
    21.12
    Author:
    Aleks Seovic 2020.12.07
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  AtomicBoolean.Serializer
      POF serializer implementation.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      AsyncAtomicBoolean async()
      Return non-blocking API for this atomic value.
      boolean compareAndExchange​(boolean fExpectedValue, boolean fNewValue)
      Atomically sets the value to newValue if the current value, referred to as the witness value, == expectedValue.
      boolean compareAndSet​(boolean fExpectedValue, boolean fNewValue)
      Atomically sets the value to newValue if the current value == expectedValue.
      boolean get()
      Returns the current value.
      boolean getAndSet​(boolean fNewValue)
      Atomically sets the value to newValue and returns the old value.
      void set​(boolean fNewValue)
      Sets the value to newValue.
    • Method Detail

      • async

        AsyncAtomicBoolean async()
        Return non-blocking API for this atomic value.
        Returns:
        non-blocking API for this atomic value
      • get

        boolean get()
        Returns the current value.
        Returns:
        the current value
      • set

        void set​(boolean fNewValue)
        Sets the value to newValue.
        Parameters:
        fNewValue - the new value
      • getAndSet

        boolean getAndSet​(boolean fNewValue)
        Atomically sets the value to newValue and returns the old value.
        Parameters:
        fNewValue - the new value
        Returns:
        the previous value
      • compareAndSet

        boolean compareAndSet​(boolean fExpectedValue,
                              boolean fNewValue)
        Atomically sets the value to newValue if the current value == expectedValue.
        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

        boolean compareAndExchange​(boolean fExpectedValue,
                                   boolean fNewValue)
        Atomically sets the value to newValue if the current value, referred to as the witness value, == expectedValue.
        Parameters:
        fExpectedValue - the expected value
        fNewValue - the new value
        Returns:
        the witness value, which will be the same as the expected value if successful