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 long
accumulateAndGet(long x, LongBinaryOperator f)
long
addAndGet(long delta)
Atomically adds to current value te given value.boolean
casVal(long expectedV, long newV)
boolean
compareAndSet(long expect, long update)
Atomically sets the value to the given updated value if the current value==
the expected value.long
decrementAndGet()
Atomically decrements the current value by one.double
doubleValue()
Returns the value of adouble
.float
floatValue()
Returns the value of afloat
.long
get()
Gets the current value.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.long
getAndAdd(long delta)
Atomically adds to the current value the given value.long
getAndAddVal(long delta)
long
getAndDecrement()
Atomically decrements the current value by 1.long
getAndIncrement()
Atomically increments the current value by 1.long
getAndSet(long newValue)
Atomically sets to the given value and returns the old value.long
getAndSetVal(long v)
long
getAndUpdate(LongUnaryOperator updateFunction)
Atomically updates the current value with the results of applying the given function, returning the previous value.long
incrementAndGet()
Atomically increments the current value by one.int
intValue()
Returns the value as anint
.void
lazySet(long newValue)
Eventually sets to the given value.long
longValue()
Returns the value as along
.long
lpVal()
long
lvVal()
void
set(long newValue)
Sets to the given value.void
soVal(long v)
void
spVal(long v)
void
svVal(long v)
String
toString()
Returns the String representation of the current value.long
updateAndGet(LongUnaryOperator updateFunction)
Atomically updates the current value with the results of applying the given function, returning the updated value.boolean
weakCompareAndSet(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:
true
if 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:
true
if 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:
intValue
in classNumber
- See Also:
AtomicLong.intValue()
-
longValue
public long longValue()
Returns the value as along
.- Specified by:
longValue
in classNumber
- See Also:
AtomicLong.longValue()
-
floatValue
public float floatValue()
Returns the value of afloat
.- Specified by:
floatValue
in classNumber
- See Also:
AtomicLong.floatValue()
-
doubleValue
public double doubleValue()
Returns the value of adouble
.- Specified by:
doubleValue
in 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)
-
-