Package com.axelor.cache.caffeine
Class AtomicLongAdapter
java.lang.Object
com.axelor.cache.caffeine.AtomicLongAdapter
- All Implemented Interfaces:
DistributedAtomicLong
Adapter class for
AtomicLong to conform to the DistributedAtomicLong interface.-
Constructor Summary
Constructors -
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.
-
Constructor Details
-
AtomicLongAdapter
-
-
Method Details
-
get
public long get()Description copied from interface:DistributedAtomicLongReturns the current value.- Specified by:
getin interfaceDistributedAtomicLong- Returns:
- the current value
-
set
public void set(long newValue) Description copied from interface:DistributedAtomicLongSets the value tonewValue.- Specified by:
setin interfaceDistributedAtomicLong- Parameters:
newValue- the new value
-
getAndSet
public long getAndSet(long newValue) Description copied from interface:DistributedAtomicLongAtomically sets the value tonewValueand returns the old value.- Specified by:
getAndSetin interfaceDistributedAtomicLong- Parameters:
newValue- the new value- Returns:
- the previous value
-
compareAndSet
public boolean compareAndSet(long expectedValue, long newValue) Description copied from interface:DistributedAtomicLongAtomically sets the value tonewValueif the current value== expectedValue.- Specified by:
compareAndSetin interfaceDistributedAtomicLong- 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
public long getAndIncrement()Description copied from interface:DistributedAtomicLongAtomically increments the current value.Equivalent to
addAndGet(1).- Specified by:
getAndIncrementin interfaceDistributedAtomicLong- Returns:
- the updated value
-
getAndDecrement
public long getAndDecrement()Description copied from interface:DistributedAtomicLongAtomically decrements the current value.- Specified by:
getAndDecrementin interfaceDistributedAtomicLong- Returns:
- the previous value
-
getAndAdd
public long getAndAdd(long delta) Description copied from interface:DistributedAtomicLongAtomically increments the current value.Equivalent to
addAndGet(1).- Specified by:
getAndAddin interfaceDistributedAtomicLong- Returns:
- the updated value
-
incrementAndGet
public long incrementAndGet()Description copied from interface:DistributedAtomicLongAtomically increments the current value by one.- Specified by:
incrementAndGetin interfaceDistributedAtomicLong- Returns:
- the updated value (value after incrementing)
-
decrementAndGet
public long decrementAndGet()Description copied from interface:DistributedAtomicLongAtomically decrements the current value.Equivalent to
addAndGet(-1).- Specified by:
decrementAndGetin interfaceDistributedAtomicLong- Returns:
- the updated value
-
addAndGet
public long addAndGet(long delta) Description copied from interface:DistributedAtomicLongAtomically adds the given value to the current value.- Specified by:
addAndGetin interfaceDistributedAtomicLong- Parameters:
delta- the value to add- Returns:
- the updated value
-
getUnderlyingAtomicLong
Description copied from interface:DistributedAtomicLongReturns underlying atomic long.- Specified by:
getUnderlyingAtomicLongin interfaceDistributedAtomicLong
-