public class MonotonicAtomicLong
extends java.util.concurrent.atomic.AtomicLong
AtomicLong
with methods that allow it to be updated only if
doing so would increase (or decrease) its value.Constructor and Description |
---|
MonotonicAtomicLong() |
Modifier and Type | Method and Description |
---|---|
long |
decrease(long newValue)
Updates the value of this
AtomicLong if it is smaller than the
current value, and returns the actual new value. |
long |
increase(long newValue)
Updates the value of this
AtomicLong if it is bigger than the
current value, and returns the actual new value. |
accumulateAndGet, addAndGet, compareAndSet, decrementAndGet, doubleValue, floatValue, get, getAndAccumulate, getAndAdd, getAndDecrement, getAndIncrement, getAndSet, getAndUpdate, incrementAndGet, intValue, lazySet, longValue, set, toString, updateAndGet, weakCompareAndSet
public long increase(long newValue)
AtomicLong
if it is bigger than the
current value, and returns the actual new value.
Implemented this way (without AtomicLong.updateAndGet(java.util.function.LongUnaryOperator)
) for compatibility
with java 1.7.newValue
- the new value to try to set.newValue
.public long decrease(long newValue)
AtomicLong
if it is smaller than the
current value, and returns the actual new value.
Implemented this way (without AtomicLong.updateAndGet(java.util.function.LongUnaryOperator)
) for compatibility
with java 1.7.newValue
- the value to try to set.newValue
.
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.