Class JmcAtomicBoolean

java.lang.Object
org.mpi_sws.jmc.api.util.concurrent.JmcAtomicBoolean

public class JmcAtomicBoolean extends Object
A redefinition of AtomicBoolean that communicates with JMC runtime to perform read, write, and compare-and-set operations.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new JmcAtomicBoolean with an initial value of false.
    JmcAtomicBoolean(boolean initialValue)
    Constructs a new JmcAtomicBoolean with the specified initial value.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    compareAndSet(boolean expectedValue, boolean newValue)
    Atomically sets the value to the given updated value if the current value is equal to the expected value.
    boolean
    get()
    Returns the current value of this atomic boolean.
    void
    set(boolean newValue)
    Sets the value of this atomic boolean to the given value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JmcAtomicBoolean

      public JmcAtomicBoolean(boolean initialValue)
      Constructs a new JmcAtomicBoolean with the specified initial value.
      Parameters:
      initialValue - the initial value of the atomic boolean
    • JmcAtomicBoolean

      public JmcAtomicBoolean()
      Constructs a new JmcAtomicBoolean with an initial value of false.
  • Method Details

    • get

      public boolean get()
      Returns the current value of this atomic boolean. Invokes a read event to the JMC runtime.
      Returns:
      the current value
    • set

      public void set(boolean newValue)
      Sets the value of this atomic boolean to the given value. Invokes a write event to the JMC runtime.
      Parameters:
      newValue - the new value to set
    • compareAndSet

      public boolean compareAndSet(boolean expectedValue, boolean newValue)
      Atomically sets the value to the given updated value if the current value is equal to the expected value. Invokes a read event followed by a write event to the JMC runtime.
      Parameters:
      expectedValue - the expected value
      newValue - the new value to set if the current value equals the expected value
      Returns:
      true if successful, false otherwise