Class AsyncRemoteAtomicBoolean
java.lang.Object
com.oracle.coherence.concurrent.atomic.AsyncRemoteAtomicBoolean
- All Implemented Interfaces:
AsyncAtomicBoolean
The remote implementation of
AsyncAtomicBoolean
, backed by a
Coherence NamedMap
entry.
Every method in this class is guaranteed to execute effectively-once, and provides
cluster-wide atomicity guarantees for the backing atomic value. However,
keep in mind that this comes at a significant cost -- each method invocation
results in a network call to a remote owner of the backing atomic value,
which means that each operation has significantly higher latency than a
corresponding local
implementation.
- Since:
- 21.12
- Author:
- Aleks Seovic 2020.12.07
-
Constructor Summary
ModifierConstructorDescriptionprotected
AsyncRemoteAtomicBoolean
(AsyncNamedMap<String, AtomicBoolean> mapAtomic, String sName) Constructs a newAsyncRemoteAtomicBoolean
. -
Method Summary
Modifier and TypeMethodDescriptioncompareAndExchange
(boolean fExpectedValue, boolean fNewValue) Atomically sets the value tonewValue
if the current value, referred to as the witness value,== expectedValue
.compareAndSet
(boolean fExpectedValue, boolean fNewValue) Atomically sets the value tonewValue
if the current value== expectedValue
.get()
Returns the current value.getAndSet
(boolean fNewValue) Atomically sets the value tonewValue
and returns the old value.protected <R> CompletableFuture
<R> invoke
(Remote.Function<AtomicBoolean, R> function) Apply specified function against the remote object and return the result.protected <R> CompletableFuture
<R> invoke
(Remote.Function<AtomicBoolean, R> function, boolean fMutate) Apply specified function against the remote object and return the result.set
(boolean fNewValue) Sets the value tonewValue
.toString()
Returns the String representation of the current value.
-
Constructor Details
-
AsyncRemoteAtomicBoolean
Constructs a newAsyncRemoteAtomicBoolean
.- Parameters:
mapAtomic
- the map that holds this atomic valuesName
- the name of this atomic value
-
-
Method Details
-
get
Description copied from interface:AsyncAtomicBoolean
Returns the current value.- Specified by:
get
in interfaceAsyncAtomicBoolean
- Returns:
- the current value
-
set
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
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
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
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
-
toString
Returns the String representation of the current value. -
invoke
Apply specified function against the remote object and return the result.Any changes the function makes to the remote object will be preserved.
- Type Parameters:
R
- the type of the result- Parameters:
function
- the function to apply- Returns:
- the result of the function applied to a remote object
-
invoke
protected <R> CompletableFuture<R> invoke(Remote.Function<AtomicBoolean, R> function, boolean fMutate) Apply specified function against the remote object and return the result.If the
fMutate
argument istrue
, any changes to the remote object will be preserved.- Type Parameters:
R
- the type of the result- Parameters:
function
- the function to applyfMutate
- flag specifying whether the function mutates the object- Returns:
- the result of the function applied to a remote object
-