Class LocalAtomicLong
- All Implemented Interfaces:
AtomicLong
,Serializable
AtomicLong
interface, that simply wraps java.util.concurrent.atomic.AtomicLong
instance.- Since:
- 21.12
- Author:
- Aleks Seovic 2020.12.03
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.oracle.coherence.concurrent.atomic.AtomicLong
AtomicLong.Serializer
-
Method Summary
Modifier and TypeMethodDescriptionlong
accumulateAndGet
(long lUpdate, Remote.LongBinaryOperator accumulatorFunction) Atomically updates the current value with the results of applying the given function to the current and given values, returning the updated value.long
accumulateAndGet
(long lUpdate, LongBinaryOperator accumulatorFunction) Atomically updates the current value with the results of applying the given function to the current and given values, returning the updated value.long
addAndGet
(long lDelta) Atomically adds the given value to the current value.async()
Return non-blocking API for this atomic value.byte
Returns the current value of thisAtomicLong
as abyte
after a narrowing primitive conversion.long
compareAndExchange
(long lExpectedValue, long lNewValue) Atomically sets the value tonewValue
if the current value, referred to as the witness value,== expectedValue
.boolean
compareAndSet
(long lExpectedValue, long lNewValue) Atomically sets the value tonewValue
if the current value== expectedValue
.long
Atomically decrements the current value.double
Returns the current value of thisAtomicLong
as adouble
after a widening primitive conversion.float
Returns the current value of thisAtomicLong
as afloat
after a widening primitive conversion.long
get()
Returns the current value.long
getAndAccumulate
(long lUpdate, Remote.LongBinaryOperator accumulatorFunction) Atomically updates the current value with the results of applying the given function to the current and given values, returning the previous value.long
getAndAccumulate
(long lUpdate, LongBinaryOperator accumulatorFunction) Atomically updates the current value with the results of applying the given function to the current and given values, returning the previous value.long
getAndAdd
(long lDelta) Atomically adds the given value to the current value.long
Atomically decrements the current value.long
Atomically increments the current value.long
getAndSet
(long lNewValue) Atomically sets the value tonewValue
and returns the old value.long
getAndUpdate
(Remote.LongUnaryOperator updateFunction) Atomically updates the current value with the results of applying the given function, returning the previous value.long
getAndUpdate
(LongUnaryOperator updateFunction) Atomically updates the current value with the results of applying the given function, returning the previous value.long
Atomically increments the current value.int
intValue()
Returns the current value of thisAtomicLong
as anint
after a narrowing primitive conversion.long
Returns the current value of thisAtomicLong
as along
.void
set
(long lNewValue) Sets the value tonewValue
.short
Returns the current value of thisAtomicLong
as ashort
after a narrowing primitive conversion.toString()
long
updateAndGet
(Remote.LongUnaryOperator updateFunction) Atomically updates the current value with the results of applying the given function, returning the updated value.long
updateAndGet
(LongUnaryOperator updateFunction) Atomically updates the current value with the results of applying the given function, returning the updated value.
-
Method Details
-
async
Description copied from interface:AtomicLong
Return non-blocking API for this atomic value.- Specified by:
async
in interfaceAtomicLong
- Returns:
- non-blocking API for this atomic value
-
get
public long get()Description copied from interface:AtomicLong
Returns the current value.- Specified by:
get
in interfaceAtomicLong
- Returns:
- the current value
-
set
public void set(long lNewValue) Description copied from interface:AtomicLong
Sets the value tonewValue
.- Specified by:
set
in interfaceAtomicLong
- Parameters:
lNewValue
- the new value
-
getAndSet
public long getAndSet(long lNewValue) Description copied from interface:AtomicLong
Atomically sets the value tonewValue
and returns the old value.- Specified by:
getAndSet
in interfaceAtomicLong
- Parameters:
lNewValue
- the new value- Returns:
- the previous value
-
compareAndSet
public boolean compareAndSet(long lExpectedValue, long lNewValue) Description copied from interface:AtomicLong
Atomically sets the value tonewValue
if the current value== expectedValue
.- Specified by:
compareAndSet
in interfaceAtomicLong
- Parameters:
lExpectedValue
- the expected valuelNewValue
- the new value- Returns:
true
if successful. False return indicates that the actual value was not equal to the expected value.
-
getAndIncrement
public long getAndIncrement()Description copied from interface:AtomicLong
Atomically increments the current value.Equivalent to
getAndAdd(1)
.- Specified by:
getAndIncrement
in interfaceAtomicLong
- Returns:
- the previous value
-
getAndDecrement
public long getAndDecrement()Description copied from interface:AtomicLong
Atomically decrements the current value.Equivalent to
getAndAdd(-1)
.- Specified by:
getAndDecrement
in interfaceAtomicLong
- Returns:
- the previous value
-
getAndAdd
public long getAndAdd(long lDelta) Description copied from interface:AtomicLong
Atomically adds the given value to the current value.- Specified by:
getAndAdd
in interfaceAtomicLong
- Parameters:
lDelta
- the value to add- Returns:
- the previous value
-
incrementAndGet
public long incrementAndGet()Description copied from interface:AtomicLong
Atomically increments the current value.Equivalent to
addAndGet(1)
.- Specified by:
incrementAndGet
in interfaceAtomicLong
- Returns:
- the updated value
-
decrementAndGet
public long decrementAndGet()Description copied from interface:AtomicLong
Atomically decrements the current value.Equivalent to
addAndGet(-1)
.- Specified by:
decrementAndGet
in interfaceAtomicLong
- Returns:
- the updated value
-
addAndGet
public long addAndGet(long lDelta) Description copied from interface:AtomicLong
Atomically adds the given value to the current value.- Specified by:
addAndGet
in interfaceAtomicLong
- Parameters:
lDelta
- the value to add- Returns:
- the updated value
-
getAndUpdate
Description copied from interface:AtomicLong
Atomically 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:
getAndUpdate
in interfaceAtomicLong
- Parameters:
updateFunction
- a side-effect-free function- Returns:
- the previous value
-
getAndUpdate
Description copied from interface:AtomicLong
Atomically 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:
getAndUpdate
in interfaceAtomicLong
- Parameters:
updateFunction
- a side-effect-free function- Returns:
- the previous value
-
updateAndGet
Description copied from interface:AtomicLong
Atomically 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:
updateAndGet
in interfaceAtomicLong
- Parameters:
updateFunction
- a side-effect-free function- Returns:
- the updated value
-
updateAndGet
Description copied from interface:AtomicLong
Atomically 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:
updateAndGet
in interfaceAtomicLong
- Parameters:
updateFunction
- a side-effect-free function- Returns:
- the updated value
-
getAndAccumulate
Description copied from interface:AtomicLong
Atomically 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:
getAndAccumulate
in interfaceAtomicLong
- Parameters:
lUpdate
- the update valueaccumulatorFunction
- a side-effect-free function of two arguments- Returns:
- the previous value
-
getAndAccumulate
Description copied from interface:AtomicLong
Atomically 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:
getAndAccumulate
in interfaceAtomicLong
- Parameters:
lUpdate
- the update valueaccumulatorFunction
- a side-effect-free function of two arguments- Returns:
- the previous value
-
accumulateAndGet
Description copied from interface:AtomicLong
Atomically 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:
accumulateAndGet
in interfaceAtomicLong
- Parameters:
lUpdate
- the update valueaccumulatorFunction
- a side-effect-free function of two arguments- Returns:
- the updated value
-
accumulateAndGet
Description copied from interface:AtomicLong
Atomically 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:
accumulateAndGet
in interfaceAtomicLong
- Parameters:
lUpdate
- the update valueaccumulatorFunction
- a side-effect-free function of two arguments- Returns:
- the updated value
-
compareAndExchange
public long compareAndExchange(long lExpectedValue, long lNewValue) Description copied from interface:AtomicLong
Atomically sets the value tonewValue
if the current value, referred to as the witness value,== expectedValue
.- Specified by:
compareAndExchange
in interfaceAtomicLong
- Parameters:
lExpectedValue
- the expected valuelNewValue
- the new value- Returns:
- the witness value, which will be the same as the expected value if successful
-
intValue
public int intValue()Description copied from interface:AtomicLong
Returns the current value of thisAtomicLong
as anint
after a narrowing primitive conversion.- Specified by:
intValue
in interfaceAtomicLong
- Specified by:
intValue
in classNumber
- Returns:
- the numeric value represented by this object after conversion
to type
int
-
longValue
public long longValue()Description copied from interface:AtomicLong
Returns the current value of thisAtomicLong
as along
.- Specified by:
longValue
in interfaceAtomicLong
- Specified by:
longValue
in classNumber
- Returns:
- the numeric value represented by this object
-
floatValue
public float floatValue()Description copied from interface:AtomicLong
Returns the current value of thisAtomicLong
as afloat
after a widening primitive conversion.- Specified by:
floatValue
in interfaceAtomicLong
- Specified by:
floatValue
in classNumber
- Returns:
- the numeric value represented by this object after conversion
to type
float
-
doubleValue
public double doubleValue()Description copied from interface:AtomicLong
Returns the current value of thisAtomicLong
as adouble
after a widening primitive conversion.- Specified by:
doubleValue
in interfaceAtomicLong
- Specified by:
doubleValue
in classNumber
- Returns:
- the numeric value represented by this object after conversion
to type
double
-
byteValue
public byte byteValue()Description copied from interface:AtomicLong
Returns the current value of thisAtomicLong
as abyte
after a narrowing primitive conversion.- Specified by:
byteValue
in interfaceAtomicLong
- Overrides:
byteValue
in classNumber
- Returns:
- the numeric value represented by this object after conversion
to type
byte
-
shortValue
public short shortValue()Description copied from interface:AtomicLong
Returns the current value of thisAtomicLong
as ashort
after a narrowing primitive conversion.- Specified by:
shortValue
in interfaceAtomicLong
- Overrides:
shortValue
in classNumber
- Returns:
- the numeric value represented by this object after conversion
to type
short
-
toString
-