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 TypeMethodDescriptionlongaddAndGet(long delta) Atomically adds the given value to the current value.booleancompareAndSet(long expectedValue, long newValue) Atomically sets the value tonewValueif the current value== expectedValue.longAtomically decrements the current value.longget()Returns the current value.longgetAndAdd(long delta) Atomically increments the current value.longAtomically decrements the current value.longAtomically increments the current value.longgetAndSet(long newValue) Atomically sets the value tonewValueand returns the old value.Returns underlying atomic long.longAtomically increments the current value by one.voidset(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 tonewValueand returns the old value.- Parameters:
newValue- the new value- Returns:
- the previous value
-
compareAndSet
boolean compareAndSet(long expectedValue, long newValue) Atomically sets the value tonewValueif the current value== expectedValue.- Parameters:
expectedValue- the expected valuenewValue- the new value- Returns:
trueif 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.
-