Atomic pointer.
More...
Detailed Description
Atomic pointer.
This will be the natural width of the pointer on the runtime platform.
Use AtomicPX for safer pointer storage.
Typedef Documentation
An opaque reference to the Plank AtomicP object (atomic pointer).
Function Documentation
static PlankP pl_AtomicP_Add |
( |
PlankAtomicPRef |
p, |
|
|
PlankL |
operand |
|
) |
| [static] |
Offset current pointer.
- Parameters:
-
p | The Plank AtomicP object. |
operand | The number of bytes by which to offset. |
- Returns:
- The new pointer.
static PlankB pl_AtomicP_CompareAndSwap |
( |
PlankAtomicPRef |
p, |
|
|
PlankP |
oldPtr, |
|
|
PlankP |
newPtr |
|
) |
| [static] |
Swap the current pointer with a new pointer if a specified old pointer is still current.
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 pointer again and retrying to write the new pointer (e.g., in a loop) until successful. If there are no other threads contending to write the pointer the operation should succeed without blocking.
- Parameters:
-
p | The Plank AtomicP object. |
oldPtr | The expected old pointer being currently stored. |
newPtr | The new pointer to attempt to store. |
- Returns:
true
if the swap was successful, otherwise false
.
Create a Plank AtomicD object and return an oqaque reference to it.
- Returns:
- A Plank AtomicD object as an opaque reference or PLANK_NULL.
Creates and initialises a Plank AtomicP object and return an oqaque reference to it.
- Returns:
- A Plank AtomicP object as an opaque reference or PLANK_NULL.
Decrement the current pointer by 1 byte.
- Parameters:
-
p | The Plank AtomicP object. |
- Returns:
- The new pointer.
Deinitialise a Plank AtomicP object.
- Parameters:
-
p | The Plank AtomicP object. |
- Returns:
- PlankResult_OK if successful, otherwise an error code.
Destroy a Plank AtomicP object.
- Parameters:
-
p | The Plank AtomicP object. |
- Returns:
- PlankResult_OK if successful, otherwise an error code.
Get the current value.
- Parameters:
-
p | The Plank AtomicP object. |
- Returns:
- The value.
Not used for this class.
Use AtomicPX for safer pointer storage.
- Parameters:
-
p | The Plank AtomicI object. |
- Returns:
- Always returns 0.
Not used for this class.
Use AtomicPX for safer pointer storage.
- Parameters:
-
p | The Plank AtomicI object. |
- Returns:
- Always returns 0.
Get the current value nonatomically.
- Parameters:
-
p | The Plank AtomicP object. |
- Returns:
- The value.
Increment the current pointer by 1 byte.
- Parameters:
-
p | The Plank AtomicP object. |
- Returns:
- The new pointer.
Initialise a Plank AtomicP object.
- Parameters:
-
p | The Plank AtomicP object. |
- Returns:
- PlankResult_OK if successful, otherwise an error code.
Set the current pointer to a new pointer.
- Parameters:
-
p | The Plank AtomicP object. |
newPtr | The new pointer to store. |
static PlankP pl_AtomicP_Subtract |
( |
PlankAtomicPRef |
p, |
|
|
PlankL |
operand |
|
) |
| [static] |
Offset current pointer in a negative direct.
- Parameters:
-
p | The Plank AtomicP object. |
operand | The number of bytes to subtract from the pointer. |
- Returns:
- The new pointer.
static PlankP pl_AtomicP_Swap |
( |
PlankAtomicPRef |
p, |
|
|
PlankP |
newPtr |
|
) |
| [static] |
Swap the current pointer with a new pointer.
- Parameters:
-
p | The Plank AtomicP object. |
newPtr | The new value to store. |
- Returns:
- The previously stored pointer.
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 AtomicP object. |
p2 | The other Plank AtomicP object. |