Package org.jctools.util
Class PaddedAtomicLong
- java.lang.Object
-
- java.lang.Number
-
- org.jctools.util.PaddedAtomicLong
-
- All Implemented Interfaces:
Serializable
public class PaddedAtomicLong extends Number
A padded version of theAtomicLong.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PaddedAtomicLong()Creates a new PaddedAtomicLong with initial value0.PaddedAtomicLong(long initialValue)Creates a new PaddedAtomicLong with the given initial value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longaccumulateAndGet(long x, LongBinaryOperator f)longaddAndGet(long delta)Atomically adds to current value te given value.booleancasVal(long expectedV, long newV)booleancompareAndSet(long expect, long update)Atomically sets the value to the given updated value if the current value==the expected value.longdecrementAndGet()Atomically decrements the current value by one.doubledoubleValue()Returns the value of adouble.floatfloatValue()Returns the value of afloat.longget()Gets the current value.longgetAndAccumulate(long v, LongBinaryOperator f)Atomically updates the current value with the results of applying the given function to the current and given values, returning the previous value.longgetAndAdd(long delta)Atomically adds to the current value the given value.longgetAndAddVal(long delta)longgetAndDecrement()Atomically decrements the current value by 1.longgetAndIncrement()Atomically increments the current value by 1.longgetAndSet(long newValue)Atomically sets to the given value and returns the old value.longgetAndSetVal(long v)longgetAndUpdate(LongUnaryOperator updateFunction)Atomically updates the current value with the results of applying the given function, returning the previous value.longincrementAndGet()Atomically increments the current value by one.intintValue()Returns the value as anint.voidlazySet(long newValue)Eventually sets to the given value.longlongValue()Returns the value as along.longlpVal()longlvVal()voidset(long newValue)Sets to the given value.voidsoVal(long v)voidspVal(long v)voidsvVal(long v)StringtoString()Returns the String representation of the current value.longupdateAndGet(LongUnaryOperator updateFunction)Atomically updates the current value with the results of applying the given function, returning the updated value.booleanweakCompareAndSet(long expect, long update)Atomically sets the value to the given updated value if the current value==the expected value.-
Methods inherited from class java.lang.Number
byteValue, shortValue
-
-
-
-
Method Detail
-
get
public long get()
Gets the current value.- Returns:
- the current value
- See Also:
AtomicLong.get()
-
set
public void set(long newValue)
Sets to the given value.- Parameters:
newValue- the new value- See Also:
AtomicLong.set(long)
-
lazySet
public void lazySet(long newValue)
Eventually sets to the given value.- Parameters:
newValue- the new value- See Also:
AtomicLong.lazySet(long)
-
getAndSet
public long getAndSet(long newValue)
Atomically sets to the given value and returns the old value.- Parameters:
newValue- the new value- Returns:
- the previous value
- See Also:
AtomicLong.getAndSet(long)
-
compareAndSet
public boolean compareAndSet(long expect, long update)Atomically sets the value to the given updated value if the current value==the expected value.- Parameters:
expect- the expected valueupdate- the new value- Returns:
trueif successful. False return indicates that the actual value was not equal to the expected value.- See Also:
AtomicLong.compareAndSet(long, long)
-
weakCompareAndSet
public boolean weakCompareAndSet(long expect, long update)Atomically sets the value to the given updated value if the current value==the expected value.May fail spuriously and does not provide ordering guarantees, so is only rarely an appropriate alternative to
compareAndSet.- Parameters:
expect- the expected valueupdate- the new value- Returns:
trueif successful- See Also:
AtomicLong.weakCompareAndSet(long, long)
-
getAndIncrement
public long getAndIncrement()
Atomically increments the current value by 1.- Returns:
- the previous value
- See Also:
AtomicLong.getAndIncrement()
-
getAndDecrement
public long getAndDecrement()
Atomically decrements the current value by 1.- Returns:
- the previous value
- See Also:
AtomicLong.getAndDecrement()
-
getAndAdd
public long getAndAdd(long delta)
Atomically adds to the current value the given value.- Parameters:
delta- the value to add- Returns:
- the previous value
- See Also:
AtomicLong.getAndAdd(long)
-
incrementAndGet
public long incrementAndGet()
Atomically increments the current value by one.- Returns:
- the updated value
- See Also:
AtomicLong.incrementAndGet()
-
decrementAndGet
public long decrementAndGet()
Atomically decrements the current value by one.- Returns:
- the updated value
- See Also:
AtomicLong.decrementAndGet()
-
addAndGet
public long addAndGet(long delta)
Atomically adds to current value te given value.- Parameters:
delta- the value to add- Returns:
- the updated value
- See Also:
AtomicLong.addAndGet(long)
-
getAndUpdate
public long getAndUpdate(LongUnaryOperator updateFunction)
Atomically updates the current value with the results of applying the given function, returning the previous value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads.- Parameters:
updateFunction- a side-effect-free function- Returns:
- the previous value
- See Also:
AtomicLong.getAndUpdate(LongUnaryOperator)
-
updateAndGet
public long updateAndGet(LongUnaryOperator updateFunction)
Atomically updates the current value with the results of applying the given function, returning the updated value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads.- Parameters:
updateFunction- a side-effect-free function- Returns:
- the updated value
- See Also:
AtomicLong.updateAndGet(LongUnaryOperator)
-
getAndAccumulate
public long getAndAccumulate(long v, LongBinaryOperator f)Atomically updates the current value with the results of applying the given function to the current and given values, returning the previous value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads. The function is applied with the current value as its first argument, and the given update as the second argument.- Parameters:
v- the update valuef- a side-effect-free function of two arguments- Returns:
- the previous value
- See Also:
AtomicLong.getAndAccumulate(long, LongBinaryOperator)
-
accumulateAndGet
public long accumulateAndGet(long x, LongBinaryOperator f)
-
toString
public String toString()
Returns the String representation of the current value.
-
intValue
public int intValue()
Returns the value as anint.- Specified by:
intValuein classNumber- See Also:
AtomicLong.intValue()
-
longValue
public long longValue()
Returns the value as along.- Specified by:
longValuein classNumber- See Also:
AtomicLong.longValue()
-
floatValue
public float floatValue()
Returns the value of afloat.- Specified by:
floatValuein classNumber- See Also:
AtomicLong.floatValue()
-
doubleValue
public double doubleValue()
Returns the value of adouble.- Specified by:
doubleValuein classNumber- See Also:
AtomicLong.doubleValue()
-
spVal
public void spVal(long v)
-
soVal
public void soVal(long v)
-
svVal
public void svVal(long v)
-
lvVal
public long lvVal()
-
lpVal
public long lpVal()
-
casVal
public boolean casVal(long expectedV, long newV)
-
getAndSetVal
public long getAndSetVal(long v)
-
getAndAddVal
public long getAndAddVal(long delta)
-
-