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