pl-nk v0.4.5
Plonk|Plink|Plank are a set of cross-platform C/C++ frameworks for audio software development
Typedefs | Functions
Plank AtomicD class
Plank Atomic operation classes

Atomic double. More...

Typedefs

typedef struct PlankAtomicD * PlankAtomicDRef
 An opaque reference to the Plank AtomicD object (atomic double).

Functions

PlankAtomicDRef pl_AtomicD_CreateAndInit ()
 Creates and initialises a Plank AtomicD object and return an oqaque reference to it.
PlankAtomicDRef pl_AtomicD_Create ()
 Create a Plank AtomicF object and return an oqaque reference to it.
static PlankResult pl_AtomicD_Init (PlankAtomicDRef p)
 Initialise a Plank AtomicD object.
static PlankResult pl_AtomicD_DeInit (PlankAtomicDRef p)
 Deinitialise a Plank AtomicD object.
PlankResult pl_AtomicD_Destroy (PlankAtomicDRef p)
 Destroy a Plank AtomicD object.
static PlankD pl_AtomicD_Get (PlankAtomicDRef p)
 Get the current value.
static PlankD pl_AtomicD_GetUnchecked (PlankAtomicDRef p)
 Get the current value nonatomically.
PlankULL pl_AtomicD_GetExtra (PlankAtomicDRef p)
 Not used for this class.
PlankULL pl_AtomicD_GetExtraUnchecked (PlankAtomicDRef p)
 Not used for this class.
static PlankD pl_AtomicD_Swap (PlankAtomicDRef p, PlankD newValue)
 Swap the current value with a new value.
static void pl_AtomicD_SwapOther (PlankAtomicDRef p1, PlankAtomicDRef p2)
 Swap over two values.
static void pl_AtomicD_Set (PlankAtomicDRef p, PlankD newValue)
 Set the current value to a new value.
static PlankD pl_AtomicD_Add (PlankAtomicDRef p, PlankD operand)
 Add a value to the current value.
static PlankD pl_AtomicD_Subtract (PlankAtomicDRef p, PlankD operand)
 Subtract a value from the current value.
static PlankD pl_AtomicD_Increment (PlankAtomicDRef p)
 Increment the current value by 1.
static PlankD pl_AtomicD_Decrement (PlankAtomicDRef p)
 Decrement the current value by 1.
static PlankB pl_AtomicD_CompareAndSwap (PlankAtomicDRef p, PlankD oldValue, PlankD newValue)
 Swap the current value with a new value if a specified old value is still the current value.

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

typedef struct PlankAtomicD* PlankAtomicDRef

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:
pThe Plank AtomicD object.
operandThe 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:
pThe Plank AtomicD object.
oldValueThe expected old value being currently stored.
newValueThe new value to attempt to store.
Returns:
true if the swap was successful, otherwise false.
PlankAtomicDRef pl_AtomicD_Create ( )

Create a Plank AtomicF object and return an oqaque reference to it.

Returns:
A Plank AtomicF object as an opaque reference or PLANK_NULL.
PlankAtomicDRef pl_AtomicD_CreateAndInit ( )

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.
static PlankD pl_AtomicD_Decrement ( PlankAtomicDRef  p) [static]

Decrement the current value by 1.

Parameters:
pThe Plank AtomicD object.
Returns:
The new value.
static PlankResult pl_AtomicD_DeInit ( PlankAtomicDRef  p) [static]

Deinitialise a Plank AtomicD object.

Parameters:
pThe Plank AtomicD object.
Returns:
PlankResult_OK if successful, otherwise an error code.
PlankResult pl_AtomicD_Destroy ( PlankAtomicDRef  p)

Destroy a Plank AtomicD object.

Parameters:
pThe Plank AtomicD object.
Returns:
PlankResult_OK if successful, otherwise an error code.
static PlankD pl_AtomicD_Get ( PlankAtomicDRef  p) [static]

Get the current value.

Parameters:
pThe Plank AtomicD object.
Returns:
The value.
PlankULL pl_AtomicD_GetExtra ( PlankAtomicDRef  p)

Not used for this class.

Parameters:
pThe Plank AtomicD object.
Returns:
Always returns 0.
PlankULL pl_AtomicD_GetExtraUnchecked ( PlankAtomicDRef  p)

Not used for this class.

Parameters:
pThe Plank AtomicD object.
Returns:
Always returns 0.
static PlankD pl_AtomicD_GetUnchecked ( PlankAtomicDRef  p) [static]

Get the current value nonatomically.

Parameters:
pThe Plank AtomicD object.
Returns:
The value.
static PlankD pl_AtomicD_Increment ( PlankAtomicDRef  p) [static]

Increment the current value by 1.

Parameters:
pThe Plank AtomicD object.
Returns:
The new value.
static PlankResult pl_AtomicD_Init ( PlankAtomicDRef  p) [static]

Initialise a Plank AtomicD object.

Parameters:
pThe Plank AtomicD object.
Returns:
PlankResult_OK if successful, otherwise an error code.
static void pl_AtomicD_Set ( PlankAtomicDRef  p,
PlankD  newValue 
) [static]

Set the current value to a new value.

Parameters:
pThe Plank AtomicD object.
newValueThe new value to store.
static PlankD pl_AtomicD_Subtract ( PlankAtomicDRef  p,
PlankD  operand 
) [static]

Subtract a value from the current value.

Parameters:
pThe Plank AtomicD object.
operandThe 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:
pThe Plank AtomicD object.
newValueThe new value to store.
Returns:
The previously stored value.
static void pl_AtomicD_SwapOther ( PlankAtomicDRef  p1,
PlankAtomicDRef  p2 
) [static]

Swap over two values.

The contents of p1 is copied to p2 and p2 is copied to p1 in an atomic operation.

Parameters:
p1One Plank AtomicD object.
p2The other Plank AtomicD object.
 All Classes Functions Typedefs Enumerations Enumerator Properties