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 ClassesModifier and TypeInterfaceDescriptionstatic classPOF serializer implementation. -
Method Summary
Modifier and TypeMethodDescriptionasync()Return non-blocking API for this atomic value.booleancompareAndExchange(boolean fExpectedValue, boolean fNewValue) Atomically sets the value tonewValueif the current value, referred to as the witness value,== expectedValue.booleancompareAndSet(boolean fExpectedValue, boolean fNewValue) Atomically sets the value tonewValueif the current value== expectedValue.booleanget()Returns the current value.booleangetAndSet(boolean fNewValue) Atomically sets the value tonewValueand returns the old value.voidset(boolean fNewValue) Sets the value tonewValue.
-
Method Details
-
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 tonewValue.- Parameters:
fNewValue- the new value
-
getAndSet
boolean getAndSet(boolean fNewValue) Atomically sets the value tonewValueand returns the old value.- Parameters:
fNewValue- the new value- Returns:
- the previous value
-
compareAndSet
boolean compareAndSet(boolean fExpectedValue, boolean fNewValue) Atomically sets the value tonewValueif the current value== expectedValue.- Parameters:
fExpectedValue- the expected valuefNewValue- the new value- Returns:
trueif 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 tonewValueif the current value, referred to as the witness value,== expectedValue.- Parameters:
fExpectedValue- the expected valuefNewValue- the new value- Returns:
- the witness value, which will be the same as the expected value if successful
-