Class RemoteAtomicBoolean
java.lang.Object
com.oracle.coherence.concurrent.atomic.RemoteAtomicBoolean
- All Implemented Interfaces:
AtomicBoolean
The remote implementation of
AtomicBoolean
,
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.
To somewhat reduce that performance penalty, consider using non-blocking
AsyncAtomicBoolean
implementation instead.
- Since:
- 21.06
- Author:
- Aleks Seovic 2020.12.07
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.oracle.coherence.concurrent.atomic.AtomicBoolean
AtomicBoolean.Serializer
-
Constructor Summary
ModifierConstructorDescriptionprotected
RemoteAtomicBoolean
(NamedMap<String, AtomicBoolean> mapAtomic, String sName) ConstructRemoteAtomicBoolean
instance. -
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.protected <R> R
invoke
(Remote.Function<AtomicBoolean, R> function) Apply specified function against the remote object and return the result.protected <R> R
invoke
(Remote.Function<AtomicBoolean, R> function, boolean fMutate) Apply specified function against the remote object and return the result.void
set
(boolean fNewValue) Sets the value tonewValue
.toString()
Returns the String representation of the current value.
-
Constructor Details
-
RemoteAtomicBoolean
ConstructRemoteAtomicBoolean
instance.- Parameters:
mapAtomic
- the map that holds this atomic valuesName
- the name of this atomic value
-
-
Method Details
-
async
Description copied from interface:AtomicBoolean
Return non-blocking API for this atomic value.- Specified by:
async
in interfaceAtomicBoolean
- Returns:
- non-blocking API for this atomic value
-
get
public boolean get()Description copied from interface:AtomicBoolean
Returns the current value.- Specified by:
get
in interfaceAtomicBoolean
- Returns:
- the current value
-
set
public void set(boolean fNewValue) Description copied from interface:AtomicBoolean
Sets the value tonewValue
.- Specified by:
set
in interfaceAtomicBoolean
- Parameters:
fNewValue
- the new value
-
getAndSet
public boolean getAndSet(boolean fNewValue) Description copied from interface:AtomicBoolean
Atomically sets the value tonewValue
and returns the old value.- Specified by:
getAndSet
in interfaceAtomicBoolean
- Parameters:
fNewValue
- the new value- Returns:
- the previous value
-
compareAndSet
public boolean compareAndSet(boolean fExpectedValue, boolean fNewValue) Description copied from interface:AtomicBoolean
Atomically sets the value tonewValue
if the current value== expectedValue
.- Specified by:
compareAndSet
in interfaceAtomicBoolean
- 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 boolean compareAndExchange(boolean fExpectedValue, boolean fNewValue) Description copied from interface:AtomicBoolean
Atomically sets the value tonewValue
if the current value, referred to as the witness value,== expectedValue
.- Specified by:
compareAndExchange
in interfaceAtomicBoolean
- 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
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
-