Class RemoteAtomicBoolean
- java.lang.Object
-
- com.oracle.coherence.concurrent.atomic.RemoteAtomicBoolean
-
- All Implemented Interfaces:
AtomicBoolean
public class RemoteAtomicBoolean extends Object implements AtomicBoolean
The remote implementation ofAtomicBoolean, backed by a CoherenceNamedMapentry.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
localimplementation.To somewhat reduce that performance penalty, consider using non-blocking
AsyncAtomicBooleanimplementation 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
Constructors Modifier Constructor Description protectedRemoteAtomicBoolean(NamedMap<String,AtomicBoolean> mapAtomic, String sName)ConstructRemoteAtomicBooleaninstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AsyncRemoteAtomicBooleanasync()Return non-blocking API for this atomic value.booleancompareAndExchange(boolean fExpectedValue, boolean fNewValue)Atomically sets the value tonewValueif the current value, referred to as the witness value,== expectedValue.booleancompareAndSet(boolean fExpectedValue, boolean fNewValue)Atomically sets the value tonewValueif the current value== expectedValue.booleanget()Returns the current value.booleangetAndSet(boolean fNewValue)Atomically sets the value tonewValueand returns the old value.protected <R> Rinvoke(Remote.Function<AtomicBoolean,R> function)Apply specified function against the remote object and return the result.protected <R> Rinvoke(Remote.Function<AtomicBoolean,R> function, boolean fMutate)Apply specified function against the remote object and return the result.voidset(boolean fNewValue)Sets the value tonewValue.StringtoString()Returns the String representation of the current value.
-
-
-
Constructor Detail
-
RemoteAtomicBoolean
protected RemoteAtomicBoolean(NamedMap<String,AtomicBoolean> mapAtomic, String sName)
ConstructRemoteAtomicBooleaninstance.- Parameters:
mapAtomic- the map that holds this atomic valuesName- the name of this atomic value
-
-
Method Detail
-
async
public AsyncRemoteAtomicBoolean async()
Description copied from interface:AtomicBooleanReturn non-blocking API for this atomic value.- Specified by:
asyncin interfaceAtomicBoolean- Returns:
- non-blocking API for this atomic value
-
get
public boolean get()
Description copied from interface:AtomicBooleanReturns the current value.- Specified by:
getin interfaceAtomicBoolean- Returns:
- the current value
-
set
public void set(boolean fNewValue)
Description copied from interface:AtomicBooleanSets the value tonewValue.- Specified by:
setin interfaceAtomicBoolean- Parameters:
fNewValue- the new value
-
getAndSet
public boolean getAndSet(boolean fNewValue)
Description copied from interface:AtomicBooleanAtomically sets the value tonewValueand returns the old value.- Specified by:
getAndSetin interfaceAtomicBoolean- Parameters:
fNewValue- the new value- Returns:
- the previous value
-
compareAndSet
public boolean compareAndSet(boolean fExpectedValue, boolean fNewValue)Description copied from interface:AtomicBooleanAtomically sets the value tonewValueif the current value== expectedValue.- Specified by:
compareAndSetin interfaceAtomicBoolean- 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 boolean compareAndExchange(boolean fExpectedValue, boolean fNewValue)Description copied from interface:AtomicBooleanAtomically sets the value tonewValueif the current value, referred to as the witness value,== expectedValue.- Specified by:
compareAndExchangein 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
public String toString()
Returns the String representation of the current value.
-
invoke
protected <R> R invoke(Remote.Function<AtomicBoolean,R> function)
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> R invoke(Remote.Function<AtomicBoolean,R> function, boolean fMutate)
Apply specified function against the remote object and return the result.If the
fMutateargument 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
-
-