Class PaddedAtomicLong
java.lang.Object
java.lang.Number
org.jctools.util.PaddedAtomicLongL1Pad
org.jctools.util.PaddedAtomicLongL1Field
org.jctools.util.PaddedAtomicLongL2Pad
org.jctools.util.PaddedAtomicLong
- All Implemented Interfaces:
Serializable
A padded version of the
AtomicLong.- See Also:
-
Field Summary
Fields inherited from class PaddedAtomicLongL2Pad
b000, b001, b002, b003, b004, b005, b006, b007, b010, b011, b012, b013, b014, b015, b016, b017, b020, b021, b022, b023, b024, b025, b026, b027, b030, b031, b032, b033, b034, b035, b036, b037, b040, b041, b042, b043, b044, b045, b046, b047, b050, b051, b052, b053, b054, b055, b056, b057, b060, b061, b062, b063, b064, b065, b066, b067, b070, b071, b072, b073, b074, b075, b076, b077, b100, b101, b102, b103, b104, b105, b106, b107, b110, b111, b112, b113, b114, b115, b116, b117, b120, b121, b122, b123, b124, b125, b126, b127, b130, b131, b132, b133, b134, b135, b136, b137, b140, b141, b142, b143, b144, b145, b146, b147, b150, b151, b152, b153, b154, b155, b156, b157, b160, b161, b162, b163, b164, b165, b166, b167, b170, b171, b172, b173, b174, b175, b176, b177 -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new PaddedAtomicLong with initial value0.PaddedAtomicLong(long initialValue) Creates a new PaddedAtomicLong with the given initial value. -
Method Summary
Modifier and TypeMethodDescriptionlongaccumulateAndGet(long x, LongBinaryOperator f) longaddAndGet(long delta) Atomically adds to current value te given value.booleancompareAndSet(long expect, long update) Atomically sets the value to the given updated value if the current value==the expected value.longAtomically decrements the current value by one.doubleReturns the value of adouble.floatReturns 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.longAtomically decrements the current value by 1.longAtomically increments the current value by 1.longgetAndSet(long newValue) Atomically sets to the given value and returns the old value.longgetAndUpdate(LongUnaryOperator updateFunction) Atomically updates the current value with the results of applying the given function, returning the previous value.longAtomically increments the current value by one.intintValue()Returns the value as anint.voidlazySet(long newValue) Eventually sets to the given value.longReturns the value as along.voidset(long newValue) Sets to the given value.toString()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 PaddedAtomicLongL1Field
casVal, getAndAddVal, getAndSetVal, lpVal, lvVal, soVal, spVal, svValMethods inherited from class Number
byteValue, shortValue
-
Constructor Details
-
PaddedAtomicLong
public PaddedAtomicLong()Creates a new PaddedAtomicLong with initial value0. -
PaddedAtomicLong
public PaddedAtomicLong(long initialValue) Creates a new PaddedAtomicLong with the given initial value.- Parameters:
initialValue- the initial value
-
-
Method Details
-
get
public long get()Gets the current value.- Returns:
- the current value
- See Also:
-
set
public void set(long newValue) Sets to the given value.- Parameters:
newValue- the new value- See Also:
-
lazySet
public void lazySet(long newValue) Eventually sets to the given value.- Parameters:
newValue- the new value- See Also:
-
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:
-
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:
-
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:
-
getAndIncrement
public long getAndIncrement()Atomically increments the current value by 1.- Returns:
- the previous value
- See Also:
-
getAndDecrement
public long getAndDecrement()Atomically decrements the current value by 1.- Returns:
- the previous value
- See Also:
-
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:
-
incrementAndGet
public long incrementAndGet()Atomically increments the current value by one.- Returns:
- the updated value
- See Also:
-
decrementAndGet
public long decrementAndGet()Atomically decrements the current value by one.- Returns:
- the updated value
- See Also:
-
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:
-
getAndUpdate
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:
-
updateAndGet
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:
-
getAndAccumulate
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:
-
accumulateAndGet
-
toString
-
intValue
-
longValue
-
floatValue
public float floatValue()Returns the value of afloat.- Specified by:
floatValuein classNumber- See Also:
-
doubleValue
public double doubleValue()Returns the value of adouble.- Specified by:
doubleValuein classNumber- See Also:
-