Class AsyncLocalAtomicBoolean

java.lang.Object
com.oracle.coherence.concurrent.atomic.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 Details

    • f_fValue

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

    • AsyncLocalAtomicBoolean

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

    • get

      public CompletableFuture<Boolean> get()
      Description copied from interface: AsyncAtomicBoolean
      Returns the current value.
      Specified by:
      get in interface AsyncAtomicBoolean
      Returns:
      the current value
    • set

      public CompletableFuture<Void> set(boolean fNewValue)
      Description copied from interface: AsyncAtomicBoolean
      Sets the value to newValue.
      Specified by:
      set in interface AsyncAtomicBoolean
      Parameters:
      fNewValue - the new value
      Returns:
      a CompletableFuture that can be used to determine whether the operation completed
    • getAndSet

      public CompletableFuture<Boolean> getAndSet(boolean fNewValue)
      Description copied from interface: AsyncAtomicBoolean
      Atomically sets the value to newValue and returns the old value.
      Specified by:
      getAndSet in interface AsyncAtomicBoolean
      Parameters:
      fNewValue - the new value
      Returns:
      the previous value
    • 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