Package science.aist.jack.data
Class AtomicFloat
- java.lang.Object
-
- java.lang.Number
-
- science.aist.jack.data.AtomicFloat
-
- All Implemented Interfaces:
Serializable
public class AtomicFloat extends Number
Implementation of AtomicFloat based on
AtomicInteger
- Since:
- 2.0
- Author:
- Andreas Pointner
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AtomicFloat()
Default constructor which initializes the object with 0fAtomicFloat(float initialValue)
Constructor which initialized the object with initialValue
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
compareAndSet(float expect, float update)
Atomically sets the value to the given updated value if the current value==
the expected value.double
doubleValue()
returns the value as doublefloat
floatValue()
returns the value as floatfloat
get()
Gets the current value.float
getAndSet(float newValue)
Atomically sets to the given value and returns the old value.int
intValue()
returns the value as intlong
longValue()
returns the value as longvoid
set(float newValue)
Sets to the given value.boolean
weakCompareAndSetPlain(float expect, float 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
-
compareAndSet
public final boolean compareAndSet(float expect, float 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:
AtomicInteger.compareAndSet(int, int)
-
set
public final void set(float newValue)
Sets to the given value.- Parameters:
newValue
- the new value- See Also:
AtomicInteger.set(int)
-
get
public final float get()
Gets the current value.- Returns:
- the current value
- See Also:
AtomicInteger.get()
-
getAndSet
public final float getAndSet(float newValue)
Atomically sets to the given value and returns the old value.- Parameters:
newValue
- the new value- Returns:
- the previous value
- See Also:
AtomicInteger.getAndSet(int)
-
weakCompareAndSetPlain
public final boolean weakCompareAndSetPlain(float expect, float 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:
AtomicInteger.weakCompareAndSetPlain(int, int)
-
floatValue
public float floatValue()
returns the value as float- Specified by:
floatValue
in classNumber
- Returns:
- value as float
-
doubleValue
public double doubleValue()
returns the value as double- Specified by:
doubleValue
in classNumber
- Returns:
- value as double
-
intValue
public int intValue()
returns the value as int
-
-