Atomic double.
More...
Detailed Description
Atomic double.
This will be a 64-bit float on all Plank-supported platforms.
On PPC on Mac OS these are not a truly lock-free operations, it uses a lock due to the absence of 64-bit atomic operations.
Typedef Documentation
An opaque reference to the Plank AtomicD object (atomic double).
Function Documentation
static PlankD pl_AtomicD_Add |
( |
PlankAtomicDRef |
p, |
|
|
PlankD |
operand |
|
) |
| [static] |
Add a value to the current value.
- Parameters:
-
p | The Plank AtomicD object. |
operand | The value to add. |
- Returns:
- The new value.
static PlankB pl_AtomicD_CompareAndSwap |
( |
PlankAtomicDRef |
p, |
|
|
PlankD |
oldValue, |
|
|
PlankD |
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.0 and 0.0 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.0 and 0.0 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 AtomicD 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 AtomicD object and return an oqaque reference to it.
- Returns:
- A Plank AtomicD object as an opaque reference or PLANK_NULL.
Decrement the current value by 1.
- Parameters:
-
p | The Plank AtomicD object. |
- Returns:
- The new value.
Deinitialise a Plank AtomicD object.
- Parameters:
-
p | The Plank AtomicD object. |
- Returns:
- PlankResult_OK if successful, otherwise an error code.
Destroy a Plank AtomicD object.
- Parameters:
-
p | The Plank AtomicD object. |
- Returns:
- PlankResult_OK if successful, otherwise an error code.
Get the current value.
- Parameters:
-
p | The Plank AtomicD object. |
- Returns:
- The value.
Not used for this class.
- Parameters:
-
p | The Plank AtomicD object. |
- Returns:
- Always returns 0.
Not used for this class.
- Parameters:
-
p | The Plank AtomicD object. |
- Returns:
- Always returns 0.
Get the current value nonatomically.
- Parameters:
-
p | The Plank AtomicD object. |
- Returns:
- The value.
Increment the current value by 1.
- Parameters:
-
p | The Plank AtomicD object. |
- Returns:
- The new value.
Initialise a Plank AtomicD object.
- Parameters:
-
p | The Plank AtomicD object. |
- Returns:
- PlankResult_OK if successful, otherwise an error code.
Set the current value to a new value.
- Parameters:
-
p | The Plank AtomicD object. |
newValue | The new value to store. |
static PlankD pl_AtomicD_Subtract |
( |
PlankAtomicDRef |
p, |
|
|
PlankD |
operand |
|
) |
| [static] |
Subtract a value from the current value.
- Parameters:
-
p | The Plank AtomicD object. |
operand | The value to subtract. |
- Returns:
- The new value.
static PlankD pl_AtomicD_Swap |
( |
PlankAtomicDRef |
p, |
|
|
PlankD |
newValue |
|
) |
| [static] |
Swap the current value with a new value.
- Parameters:
-
p | The Plank AtomicD 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 AtomicD object. |
p2 | The other Plank AtomicD object. |