Class AsyncLocalAtomicBoolean
- java.lang.Object
-
- com.oracle.coherence.concurrent.atomic.AsyncLocalAtomicBoolean
-
- All Implemented Interfaces:
AsyncAtomicBoolean
public class AsyncLocalAtomicBoolean extends Object implements AsyncAtomicBoolean
Local implementation ofAsyncAtomicBoolean
interface, that simply wrapsjava.util.concurrent.atomic.AtomicBoolean
instance and returns an already completed future from each method.- Author:
- Aleks Seovic 2020.12.07
-
-
Field Summary
Fields Modifier and Type Field Description protected AtomicBoolean
f_fValue
Wrapped atomic boolean value.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AsyncLocalAtomicBoolean(AtomicBoolean value)
ConstructLocalAtomicBoolean
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletableFuture<Boolean>
compareAndExchange(boolean fExpectedValue, boolean fNewValue)
Atomically sets the value tonewValue
if the current value, referred to as the witness value,== expectedValue
.CompletableFuture<Boolean>
compareAndSet(boolean fExpectedValue, boolean fNewValue)
Atomically sets the value tonewValue
if the current value== expectedValue
.CompletableFuture<Boolean>
get()
Returns the current value.CompletableFuture<Boolean>
getAndSet(boolean fNewValue)
Atomically sets the value tonewValue
and returns the old value.CompletableFuture<Void>
set(boolean fNewValue)
Sets the value tonewValue
.String
toString()
Returns the String representation of the current value.
-
-
-
Field Detail
-
f_fValue
protected final AtomicBoolean f_fValue
Wrapped atomic boolean value.
-
-
Constructor Detail
-
AsyncLocalAtomicBoolean
protected AsyncLocalAtomicBoolean(AtomicBoolean value)
ConstructLocalAtomicBoolean
instance.- Parameters:
value
- wrapped value
-
-
Method Detail
-
get
public CompletableFuture<Boolean> get()
Description copied from interface:AsyncAtomicBoolean
Returns the current value.- Specified by:
get
in interfaceAsyncAtomicBoolean
- Returns:
- the current value
-
set
public CompletableFuture<Void> set(boolean fNewValue)
Description copied from interface:AsyncAtomicBoolean
Sets the value tonewValue
.- Specified by:
set
in interfaceAsyncAtomicBoolean
- Parameters:
fNewValue
- the new value- Returns:
- a
CompletableFuture
that can be used to determine whether the operation completed
-
getAndSet
public CompletableFuture<Boolean> getAndSet(boolean fNewValue)
Description copied from interface:AsyncAtomicBoolean
Atomically sets the value tonewValue
and returns the old value.- Specified by:
getAndSet
in interfaceAsyncAtomicBoolean
- Parameters:
fNewValue
- the new value- Returns:
- the previous value
-
compareAndSet
public CompletableFuture<Boolean> compareAndSet(boolean fExpectedValue, boolean fNewValue)
Description copied from interface:AsyncAtomicBoolean
Atomically sets the value tonewValue
if the current value== expectedValue
.- Specified by:
compareAndSet
in interfaceAsyncAtomicBoolean
- 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
public CompletableFuture<Boolean> compareAndExchange(boolean fExpectedValue, boolean fNewValue)
Description copied from interface:AsyncAtomicBoolean
Atomically sets the value tonewValue
if the current value, referred to as the witness value,== expectedValue
.- Specified by:
compareAndExchange
in interfaceAsyncAtomicBoolean
- Parameters:
fExpectedValue
- the expected valuefNewValue
- the new value- Returns:
- the witness value, which will be the same as the expected value if successful
-
-