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
Modifier and TypeInterfaceDescriptionstatic class
POF serializer implementation. -
Method Summary
Modifier and TypeMethodDescriptionasync()
Return non-blocking API for this atomic value.boolean
compareAndExchange
(boolean fExpectedValue, boolean fNewValue) Atomically sets the value tonewValue
if the current value, referred to as the witness value,== expectedValue
.boolean
compareAndSet
(boolean fExpectedValue, boolean fNewValue) Atomically sets the value tonewValue
if the current value== expectedValue
.boolean
get()
Returns the current value.boolean
getAndSet
(boolean fNewValue) Atomically sets the value tonewValue
and returns the old value.void
set
(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 tonewValue
and returns the old value.- Parameters:
fNewValue
- the new value- Returns:
- the previous value
-
compareAndSet
boolean compareAndSet(boolean fExpectedValue, boolean fNewValue) Atomically sets the value tonewValue
if the current value== expectedValue
.- Parameters:
fExpectedValue
- the expected valuefNewValue
- the new value- Returns:
true
if 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 tonewValue
if 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
-