Atomic long.
More...
Detailed Description
Atomic long.
This will be a 32-bit integer on 32-bit systems and a 64-bit integer on 64-bt systems on all Plank-supported platforms (even on Windows where a long is normally 32 bits on both architectures).
Typedef Documentation
An opaque reference to the Plank AtomicL object (atomic long integer).
Function Documentation
static PlankL pl_AtomicL_Add |
( |
PlankAtomicLRef |
p, |
|
|
PlankL |
operand |
|
) |
| [static] |
Add a value to the current value.
- Parameters:
-
p | The Plank AtomicL object. |
operand | The value to add. |
- Returns:
- The new value.
static PlankB pl_AtomicL_CompareAndSwap |
( |
PlankAtomicLRef |
p, |
|
|
PlankL |
oldValue, |
|
|
PlankL |
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.
- Parameters:
-
p | The Plank AtomicL 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 AtomicL object and return an oqaque reference to it.
- Returns:
- A Plank AtomicL object as an opaque reference or PLANK_NULL.
Creates and initialises a Plank AtomicL object and return an oqaque reference to it.
- Returns:
- A Plank AtomicL object as an opaque reference or PLANK_NULL.
Decrement the current value by 1.
- Parameters:
-
p | The Plank AtomicL object. |
- Returns:
- The new value.
Deinitialise a Plank AtomicL object.
- Parameters:
-
p | The Plank AtomicL object. |
- Returns:
- PlankResult_OK if successful, otherwise an error code.
Destroy a Plank AtomicL object.
- Parameters:
-
p | The Plank AtomicL object. |
- Returns:
- PlankResult_OK if successful, otherwise an error code.
Get the current value.
- Parameters:
-
p | The Plank AtomicL object. |
- Returns:
- The value.
Not used for this class.
- Parameters:
-
p | The Plank AtomicL object. |
- Returns:
- Always returns 0.
Not used for this class.
- Parameters:
-
p | The Plank AtomicL object. |
- Returns:
- Always returns 0.
Get the current value nonatomically.
- Parameters:
-
p | The Plank AtomicL object. |
- Returns:
- The value.
Increment the current value by 1.
- Parameters:
-
p | The Plank AtomicL object. |
- Returns:
- The new value.
Initialise a Plank AtomicL object.
- Parameters:
-
p | The Plank AtomicL object. |
- Returns:
- PlankResult_OK if successful, otherwise an error code.
Set the current value to a new value.
- Parameters:
-
p | The Plank AtomicL object. |
newValue | The new value to store. |
static PlankL pl_AtomicL_Subtract |
( |
PlankAtomicLRef |
p, |
|
|
PlankL |
operand |
|
) |
| [static] |
Subtract a value from the current value.
- Parameters:
-
p | The Plank AtomicL object. |
operand | The value to subtract. |
- Returns:
- The new value.
static PlankL pl_AtomicL_Swap |
( |
PlankAtomicLRef |
p, |
|
|
PlankL |
newValue |
|
) |
| [static] |
Swap the current value with a new value.
- Parameters:
-
p | The Plank AtomicL 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 AtomicL object. |
p2 | The other Plank AtomicL object. |