Class RemoteAtomicInteger
- java.lang.Object
- 
- java.lang.Number
- 
- com.oracle.coherence.concurrent.atomic.RemoteAtomicInteger
 
 
- 
- All Implemented Interfaces:
- AtomicInteger,- Serializable
 
 public class RemoteAtomicInteger extends Number implements AtomicInteger The remote implementation ofAtomicInteger, 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 AsyncAtomicIntegerimplementation instead.- Since:
- 21.06
- Author:
- Aleks Seovic 2020.12.03
- See Also:
- Serialized Form
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface com.oracle.coherence.concurrent.atomic.AtomicIntegerAtomicInteger.Serializer
 
- 
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedRemoteAtomicInteger(NamedMap<String,AtomicInteger> mapAtomic, String sName)ConstructRemoteAtomicIntegerinstance.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intaccumulateAndGet(int nUpdate, Remote.IntBinaryOperator accumulatorFunction)Atomically updates the current value with the results of applying the given function to the current and given values, returning the updated value.intaccumulateAndGet(int nUpdate, IntBinaryOperator accumulatorFunction)Atomically updates the current value with the results of applying the given function to the current and given values, returning the updated value.intaddAndGet(int nDelta)Atomically adds the given value to the current value.AsyncRemoteAtomicIntegerasync()Return non-blocking API for this atomic value.intcompareAndExchange(int nExpectedValue, int nNewValue)Atomically sets the value tonewValueif the current value, referred to as the witness value,== expectedValue.booleancompareAndSet(int nExpectedValue, int nNewValue)Atomically sets the value tonewValueif the current value== expectedValue.intdecrementAndGet()Atomically decrements the current value.doubledoubleValue()Returns the current value of thisAtomicIntegeras adoubleafter a widening primitive conversion.floatfloatValue()Returns the current value of thisAtomicIntegeras afloatafter a widening primitive conversion.intget()Returns the current value.intgetAndAccumulate(int nUpdate, Remote.IntBinaryOperator accumulatorFunction)Atomically updates the current value with the results of applying the given function to the current and given values, returning the previous value.intgetAndAccumulate(int nUpdate, IntBinaryOperator accumulatorFunction)Atomically updates the current value with the results of applying the given function to the current and given values, returning the previous value.intgetAndAdd(int nDelta)Atomically adds the given value to the current value.intgetAndDecrement()Atomically decrements the current value.intgetAndIncrement()Atomically increments the current value.intgetAndSet(int nNewValue)Atomically sets the value tonewValueand returns the old value.intgetAndUpdate(Remote.IntUnaryOperator updateFunction)Atomically updates the current value with the results of applying the given function, returning the previous value.intgetAndUpdate(IntUnaryOperator updateFunction)Atomically updates the current value with the results of applying the given function, returning the previous value.intincrementAndGet()Atomically increments the current value.intintValue()Returns the current value of thisAtomicIntegeras anint.protected <R> Rinvoke(Remote.Function<AtomicInteger,R> function)Apply specified function against the remote object and return the result.protected <R> Rinvoke(Remote.Function<AtomicInteger,R> function, boolean fMutate)Apply specified function against the remote object and return the result.longlongValue()Returns the current value of thisAtomicIntegeras alongafter a widening primitive conversion.voidset(int nNewValue)Sets the value tonewValue.StringtoString()Returns the String representation of the current value.intupdateAndGet(Remote.IntUnaryOperator updateFunction)Atomically updates the current value with the results of applying the given function, returning the updated value.intupdateAndGet(IntUnaryOperator updateFunction)Atomically updates the current value with the results of applying the given function, returning the updated value.- 
Methods inherited from class java.lang.NumberbyteValue, shortValue
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface com.oracle.coherence.concurrent.atomic.AtomicIntegerbyteValue, shortValue
 
- 
 
- 
- 
- 
Constructor Detail- 
RemoteAtomicIntegerprotected RemoteAtomicInteger(NamedMap<String,AtomicInteger> mapAtomic, String sName) ConstructRemoteAtomicIntegerinstance.- Parameters:
- mapAtomic- the map that holds this atomic value
- sName- the name of this atomic value
 
 
- 
 - 
Method Detail- 
asyncpublic AsyncRemoteAtomicInteger async() Description copied from interface:AtomicIntegerReturn non-blocking API for this atomic value.- Specified by:
- asyncin interface- AtomicInteger
- Returns:
- non-blocking API for this atomic value
 
 - 
getpublic int get() Description copied from interface:AtomicIntegerReturns the current value.- Specified by:
- getin interface- AtomicInteger
- Returns:
- the current value
 
 - 
setpublic void set(int nNewValue) Description copied from interface:AtomicIntegerSets the value tonewValue.- Specified by:
- setin interface- AtomicInteger
- Parameters:
- nNewValue- the new value
 
 - 
getAndSetpublic int getAndSet(int nNewValue) Description copied from interface:AtomicIntegerAtomically sets the value tonewValueand returns the old value.- Specified by:
- getAndSetin interface- AtomicInteger
- Parameters:
- nNewValue- the new value
- Returns:
- the previous value
 
 - 
compareAndSetpublic boolean compareAndSet(int nExpectedValue, int nNewValue)Description copied from interface:AtomicIntegerAtomically sets the value tonewValueif the current value== expectedValue.- Specified by:
- compareAndSetin interface- AtomicInteger
- Parameters:
- nExpectedValue- the expected value
- nNewValue- the new value
- Returns:
- trueif successful. False return indicates that the actual value was not equal to the expected value.
 
 - 
getAndIncrementpublic int getAndIncrement() Description copied from interface:AtomicIntegerAtomically increments the current value.Equivalent to getAndAdd(1).- Specified by:
- getAndIncrementin interface- AtomicInteger
- Returns:
- the previous value
 
 - 
getAndDecrementpublic int getAndDecrement() Description copied from interface:AtomicIntegerAtomically decrements the current value.Equivalent to getAndAdd(-1).- Specified by:
- getAndDecrementin interface- AtomicInteger
- Returns:
- the previous value
 
 - 
getAndAddpublic int getAndAdd(int nDelta) Description copied from interface:AtomicIntegerAtomically adds the given value to the current value.- Specified by:
- getAndAddin interface- AtomicInteger
- Parameters:
- nDelta- the value to add
- Returns:
- the previous value
 
 - 
incrementAndGetpublic int incrementAndGet() Description copied from interface:AtomicIntegerAtomically increments the current value.Equivalent to addAndGet(1).- Specified by:
- incrementAndGetin interface- AtomicInteger
- Returns:
- the updated value
 
 - 
decrementAndGetpublic int decrementAndGet() Description copied from interface:AtomicIntegerAtomically decrements the current value.Equivalent to addAndGet(-1).- Specified by:
- decrementAndGetin interface- AtomicInteger
- Returns:
- the updated value
 
 - 
addAndGetpublic int addAndGet(int nDelta) Description copied from interface:AtomicIntegerAtomically adds the given value to the current value.- Specified by:
- addAndGetin interface- AtomicInteger
- Parameters:
- nDelta- the value to add
- Returns:
- the updated value
 
 - 
getAndUpdatepublic int getAndUpdate(Remote.IntUnaryOperator updateFunction) Description copied from interface:AtomicIntegerAtomically updates the current value with the results of applying the given function, returning the previous value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads.- Specified by:
- getAndUpdatein interface- AtomicInteger
- Parameters:
- updateFunction- a side-effect-free function
- Returns:
- the previous value
 
 - 
getAndUpdatepublic int getAndUpdate(IntUnaryOperator updateFunction) Description copied from interface:AtomicIntegerAtomically updates the current value with the results of applying the given function, returning the previous value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads.- Specified by:
- getAndUpdatein interface- AtomicInteger
- Parameters:
- updateFunction- a side-effect-free function
- Returns:
- the previous value
 
 - 
updateAndGetpublic int updateAndGet(Remote.IntUnaryOperator updateFunction) Description copied from interface:AtomicIntegerAtomically updates the current value with the results of applying the given function, returning the updated value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads.- Specified by:
- updateAndGetin interface- AtomicInteger
- Parameters:
- updateFunction- a side-effect-free function
- Returns:
- the updated value
 
 - 
updateAndGetpublic int updateAndGet(IntUnaryOperator updateFunction) Description copied from interface:AtomicIntegerAtomically updates the current value with the results of applying the given function, returning the updated value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads.- Specified by:
- updateAndGetin interface- AtomicInteger
- Parameters:
- updateFunction- a side-effect-free function
- Returns:
- the updated value
 
 - 
getAndAccumulatepublic int getAndAccumulate(int nUpdate, Remote.IntBinaryOperator accumulatorFunction)Description copied from interface:AtomicIntegerAtomically updates the current value with the results of applying the given function to the current and given values, returning the previous value.The function should beside-effect-free, since it may be re-applied when attempted updates fail due to contention among threads. The function is applied with the current value as its first argument, and the given update as the second argument. - Specified by:
- getAndAccumulatein interface- AtomicInteger
- Parameters:
- nUpdate- the update value
- accumulatorFunction- a side-effect-free function of two arguments
- Returns:
- the previous value
 
 - 
getAndAccumulatepublic int getAndAccumulate(int nUpdate, IntBinaryOperator accumulatorFunction)Description copied from interface:AtomicIntegerAtomically updates the current value with the results of applying the given function to the current and given values, returning the previous value.The function should beside-effect-free, since it may be re-applied when attempted updates fail due to contention among threads. The function is applied with the current value as its first argument, and the given update as the second argument. - Specified by:
- getAndAccumulatein interface- AtomicInteger
- Parameters:
- nUpdate- the update value
- accumulatorFunction- a side-effect-free function of two arguments
- Returns:
- the previous value
 
 - 
accumulateAndGetpublic int accumulateAndGet(int nUpdate, Remote.IntBinaryOperator accumulatorFunction)Description copied from interface:AtomicIntegerAtomically updates the current value with the results of applying the given function to the current and given values, returning the updated value.The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads. The function is applied with the current value as its first argument, and the given update as the second argument. - Specified by:
- accumulateAndGetin interface- AtomicInteger
- Parameters:
- nUpdate- the update value
- accumulatorFunction- a side-effect-free function of two arguments
- Returns:
- the updated value
 
 - 
accumulateAndGetpublic int accumulateAndGet(int nUpdate, IntBinaryOperator accumulatorFunction)Description copied from interface:AtomicIntegerAtomically updates the current value with the results of applying the given function to the current and given values, returning the updated value.The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads. The function is applied with the current value as its first argument, and the given update as the second argument. - Specified by:
- accumulateAndGetin interface- AtomicInteger
- Parameters:
- nUpdate- the update value
- accumulatorFunction- a side-effect-free function of two arguments
- Returns:
- the updated value
 
 - 
compareAndExchangepublic int compareAndExchange(int nExpectedValue, int nNewValue)Description copied from interface:AtomicIntegerAtomically sets the value tonewValueif the current value, referred to as the witness value,== expectedValue.- Specified by:
- compareAndExchangein interface- AtomicInteger
- Parameters:
- nExpectedValue- the expected value
- nNewValue- the new value
- Returns:
- the witness value, which will be the same as the expected value if successful
 
 - 
intValuepublic int intValue() Description copied from interface:AtomicIntegerReturns the current value of thisAtomicIntegeras anint.- Specified by:
- intValuein interface- AtomicInteger
- Specified by:
- intValuein class- Number
- Returns:
- the numeric value represented by this object
 
 - 
longValuepublic long longValue() Description copied from interface:AtomicIntegerReturns the current value of thisAtomicIntegeras alongafter a widening primitive conversion.- Specified by:
- longValuein interface- AtomicInteger
- Specified by:
- longValuein class- Number
- Returns:
- the numeric value represented by this object after conversion
         to type long
 
 - 
floatValuepublic float floatValue() Description copied from interface:AtomicIntegerReturns the current value of thisAtomicIntegeras afloatafter a widening primitive conversion.- Specified by:
- floatValuein interface- AtomicInteger
- Specified by:
- floatValuein class- Number
- Returns:
- the numeric value represented by this object after conversion
         to type float
 
 - 
doubleValuepublic double doubleValue() Description copied from interface:AtomicIntegerReturns the current value of thisAtomicIntegeras adoubleafter a widening primitive conversion.- Specified by:
- doubleValuein interface- AtomicInteger
- Specified by:
- doubleValuein class- Number
- Returns:
- the numeric value represented by this object after conversion
         to type double
 
 - 
toStringpublic String toString() Returns the String representation of the current value.
 - 
invokeprotected <R> R invoke(Remote.Function<AtomicInteger,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
 
 - 
invokeprotected <R> R invoke(Remote.Function<AtomicInteger,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 apply
- fMutate- flag specifying whether the function mutates the object
- Returns:
- the result of the function applied to a remote object
 
 
- 
 
-