Package com.axelor.cache
Interface DistributedAtomicLong
- All Known Implementing Classes:
AtomicLongAdapter
,RedissonAtomicLongAdapter
public interface DistributedAtomicLong
Common atomic long operations found in both
AtomicLong
and RAtomicLong
.
-
Method Summary
Modifier and TypeMethodDescriptionlong
addAndGet
(long delta) Atomically adds the given value to the current value.boolean
compareAndSet
(long expectedValue, long newValue) Atomically sets the value tonewValue
if the current value== expectedValue
.long
Atomically decrements the current value.long
get()
Returns the current value.long
getAndAdd
(long delta) Atomically increments the current value.long
Atomically decrements the current value.long
Atomically increments the current value.long
getAndSet
(long newValue) Atomically sets the value tonewValue
and returns the old value.Returns underlying atomic long.long
Atomically increments the current value by one.void
set
(long newValue) Sets the value tonewValue
.
-
Method Details
-
get
long get()Returns the current value.- Returns:
- the current value
-
set
void set(long newValue) Sets the value tonewValue
.- Parameters:
newValue
- the new value
-
getAndSet
long getAndSet(long newValue) Atomically sets the value tonewValue
and returns the old value.- Parameters:
newValue
- the new value- Returns:
- the previous value
-
compareAndSet
boolean compareAndSet(long expectedValue, long newValue) Atomically sets the value tonewValue
if the current value== expectedValue
.- Parameters:
expectedValue
- the expected valuenewValue
- the new value- Returns:
true
if successful. False return indicates that the actual value was not equal to the expected value.
-
getAndIncrement
long getAndIncrement()Atomically increments the current value.Equivalent to
addAndGet(1)
.- Returns:
- the updated value
-
getAndDecrement
long getAndDecrement()Atomically decrements the current value.- Returns:
- the previous value
-
getAndAdd
long getAndAdd(long delta) Atomically increments the current value.Equivalent to
addAndGet(1)
.- Returns:
- the updated value
-
incrementAndGet
long incrementAndGet()Atomically increments the current value by one.- Returns:
- the updated value (value after incrementing)
-
decrementAndGet
long decrementAndGet()Atomically decrements the current value.Equivalent to
addAndGet(-1)
.- Returns:
- the updated value
-
addAndGet
long addAndGet(long delta) Atomically adds the given value to the current value.- Parameters:
delta
- the value to add- Returns:
- the updated value
-
getUnderlyingAtomicLong
Object getUnderlyingAtomicLong()Returns underlying atomic long.
-