Interface AtomicBoolean
-
- All Known Implementing Classes:
LocalAtomicBoolean,RemoteAtomicBoolean
public interface AtomicBooleanAbooleanvalue that may be updated atomically.An
AtomicBooleanis used in applications such as atomically updated flags, and cannot be used as a replacement for aBoolean.- Since:
- 21.12
- Author:
- Aleks Seovic 2020.12.07
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classAtomicBoolean.SerializerPOF serializer implementation.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description AsyncAtomicBooleanasync()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 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 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
-
-