Class JmcAtomicBoolean
java.lang.Object
org.mpi_sws.jmc.api.util.concurrent.JmcAtomicBoolean
A redefinition of
AtomicBoolean that communicates with JMC
runtime to perform read, write, and compare-and-set operations.-
Constructor Summary
ConstructorsConstructorDescriptionConstructs 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 TypeMethodDescriptionbooleancompareAndSet(boolean expectedValue, boolean newValue) Atomically sets the value to the given updated value if the current value is equal to the expected value.booleanget()Returns the current value of this atomic boolean.voidset(boolean newValue) Sets the value of this atomic boolean to the given value.
-
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 valuenewValue- the new value to set if the current value equals the expected value- Returns:
- true if successful, false otherwise
-