Package org.jitsi.util.concurrent
Class MonotonicAtomicLong
- java.lang.Object
-
- java.lang.Number
-
- java.util.concurrent.atomic.AtomicLong
-
- org.jitsi.util.concurrent.MonotonicAtomicLong
-
- All Implemented Interfaces:
Serializable
public class MonotonicAtomicLong extends AtomicLong
EnrichesAtomicLongwith methods that allow it to be updated only if doing so would increase (or decrease) its value.- Author:
- Boris Grozev
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MonotonicAtomicLong()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longdecrease(long newValue)Updates the value of thisAtomicLongif it is smaller than the current value, and returns the actual new value.longincrease(long newValue)Updates the value of thisAtomicLongif it is bigger than the current value, and returns the actual new value.-
Methods inherited from class java.util.concurrent.atomic.AtomicLong
accumulateAndGet, addAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, decrementAndGet, doubleValue, floatValue, get, getAcquire, getAndAccumulate, getAndAdd, getAndDecrement, getAndIncrement, getAndSet, getAndUpdate, getOpaque, getPlain, incrementAndGet, intValue, lazySet, longValue, set, setOpaque, setPlain, setRelease, toString, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
-
Methods inherited from class java.lang.Number
byteValue, shortValue
-
-
-
-
Method Detail
-
increase
public long increase(long newValue)
Updates the value of thisAtomicLongif it is bigger than the current value, and returns the actual new value. Implemented this way (withoutAtomicLong.updateAndGet(java.util.function.LongUnaryOperator)) for compatibility with java 1.7.- Parameters:
newValue- the new value to try to set.- Returns:
- the actual new value whuch may be greater than or equal to
newValue.
-
decrease
public long decrease(long newValue)
Updates the value of thisAtomicLongif it is smaller than the current value, and returns the actual new value. Implemented this way (withoutAtomicLong.updateAndGet(java.util.function.LongUnaryOperator)) for compatibility with java 1.7.- Parameters:
newValue- the value to try to set.- Returns:
- the actual new value which may be less than or equal to
newValue.
-
-