jsat.utils.concurrent
Class AtomicDouble
- java.lang.Object
-
- jsat.utils.concurrent.AtomicDouble
-
public final class AtomicDouble extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor and Description AtomicDouble(double value)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doubleaccumulateAndGet(double x, java.util.function.DoubleBinaryOperator accumulatorFunction)Atomically updates the current value with the results of applying the given function to the current and given values, returning the updated value.doubleaddAndGet(double delta)Atomically adds the given value to the current value.booleancompareAndSet(double expect, double update)doubleget()doublegetAndAccumulate(double x, java.util.function.DoubleBinaryOperator accumulatorFunction)Atomically updates the current value with the results of applying the given function to the current and given values, returning the previous value.doublegetAndAdd(double delta)doublegetAndUpdate(java.util.function.DoubleUnaryOperator updateFunction)Atomically updates the current value with the results of applying the given function, returning the previous value.voidset(double val)java.lang.StringtoString()doubleupdateAndGet(java.util.function.DoubleUnaryOperator updateFunction)Atomically updates the current value with the results of applying the given function, returning the updated value.booleanweakCompareAndSet(double expect, double update)
-
-
-
Method Detail
-
set
public void set(double val)
-
get
public double get()
-
getAndAdd
public double getAndAdd(double delta)
-
addAndGet
public final double addAndGet(double delta)
Atomically adds the given value to the current value.- Parameters:
delta- the value to add- Returns:
- the updated value
-
updateAndGet
public final double updateAndGet(java.util.function.DoubleUnaryOperator 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
-
getAndUpdate
public final double getAndUpdate(java.util.function.DoubleUnaryOperator 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
-
getAndAccumulate
public final double getAndAccumulate(double x, java.util.function.DoubleBinaryOperator accumulatorFunction)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:
x- the update valueaccumulatorFunction- a side-effect-free function of two arguments- Returns:
- the previous value
-
accumulateAndGet
public final double accumulateAndGet(double x, java.util.function.DoubleBinaryOperator accumulatorFunction)Atomically updates the current value with the results of applying the given function to the current and given values, 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. The function is applied with the current value as its first argument, and the given update as the second argument.- Parameters:
x- the update valueaccumulatorFunction- a side-effect-free function of two arguments- Returns:
- the updated value
-
compareAndSet
public boolean compareAndSet(double expect, double update)
-
weakCompareAndSet
public boolean weakCompareAndSet(double expect, double update)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-
DataMelt 3.0 © DataMelt by jWork.ORG