Atomic float.
More...
Detailed Description
Atomic float.
This will be a 32-bit float on all Plank-supported platforms.
Typedef Documentation
An opaque reference to the Plank AtomicF object (atomic float).
Function Documentation
static PlankF pl_AtomicF_Add |
( |
PlankAtomicFRef |
p, |
|
|
PlankF |
operand |
|
) |
| [static] |
Add a value to the current value.
- Parameters:
-
p | The Plank AtomicF object. |
operand | The value to add. |
- Returns:
- The new value.
static PlankB pl_AtomicF_CompareAndSwap |
( |
PlankAtomicFRef |
p, |
|
|
PlankF |
oldValue, |
|
|
PlankF |
newValue |
|
) |
| [static] |
Swap the current value with a new value if a specified old value is still the current value.
This is the most important atomic operation for each atomic class, many other operations are based on this. If the operation fails the user would generally try again by getting the old value again and retrying to write the new value (e.g., in a loop) until successful. If there are no other threads contending to write the value the operation should succeed without blocking.
NB A bit-level comparison is performed. e.g., -0.f and 0.f would not be considered equal but two identical NaNs would be. In both of these cases this is different behaviour than comparing the two floating point values (i.e., -0.f and 0.f are considered equal and NaNs are never equal to anything else even if there's another identical NaN with which you are comparing).
- Parameters:
-
p | The Plank AtomicF object. |
oldValue | The expected old value being currently stored. |
newValue | The new value to attempt to store. |
- Returns:
true
if the swap was successful, otherwise false
.
Create a Plank AtomicF object and return an oqaque reference to it.
- Returns:
- A Plank AtomicF object as an opaque reference or PLANK_NULL.
Creates and initialises a Plank AtomicF object and return an oqaque reference to it.
- Returns:
- A Plank AtomicF object as an opaque reference or PLANK_NULL.
Decrement the current value by 1.
- Parameters:
-
p | The Plank AtomicF object. |
- Returns:
- The new value.
Deinitialise a Plank AtomicF object.
- Parameters:
-
p | The Plank AtomicF object. |
- Returns:
- PlankResult_OK if successful, otherwise an error code.
Destroy a Plank AtomicF object.
- Parameters:
-
p | The Plank AtomicF object. |
- Returns:
- PlankResult_OK if successful, otherwise an error code.
Get the current value.
- Parameters:
-
p | The Plank AtomicF object. |
- Returns:
- The value.
Not used for this class.
- Parameters:
-
p | The Plank AtomicF object. |
- Returns:
- Always returns 0.
Not used for this class.
- Parameters:
-
p | The Plank AtomicF object. |
- Returns:
- Always returns 0.
Get the current value nonatomically.
- Parameters:
-
p | The Plank AtomicF object. |
- Returns:
- The value.
Increment the current value by 1.
- Parameters:
-
p | The Plank AtomicF object. |
- Returns:
- The new value.
Initialise a Plank AtomicF object.
- Parameters:
-
p | The Plank AtomicF object. |
- Returns:
- PlankResult_OK if successful, otherwise an error code.
Set the current value to a new value.
- Parameters:
-
p | The Plank AtomicF object. |
newValue | The new value to store. |
static PlankF pl_AtomicF_Subtract |
( |
PlankAtomicFRef |
p, |
|
|
PlankF |
operand |
|
) |
| [static] |
Subtract a value from the current value.
- Parameters:
-
p | The Plank AtomicF object. |
operand | The value to subtract. |
- Returns:
- The new value.
static PlankF pl_AtomicF_Swap |
( |
PlankAtomicFRef |
p, |
|
|
PlankF |
newValue |
|
) |
| [static] |
Swap the current value with a new value.
- Parameters:
-
p | The Plank AtomicF object. |
newValue | The new value to store. |
- Returns:
- The previously stored value.
Swap over two values.
The contents of p1 is copied to p2 and p2 is copied to p1 in an atomic operation.
- Parameters:
-
p1 | One Plank AtomicF object. |
p2 | The other Plank AtomicF object. |