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

Atomic float. More...

Typedefs

typedef struct PlankAtomicF * PlankAtomicFRef
 An opaque reference to the Plank AtomicF object (atomic float).

Functions

PlankAtomicFRef pl_AtomicF_CreateAndInit ()
 Creates and initialises a Plank AtomicF object and return an oqaque reference to it.
PlankAtomicFRef pl_AtomicF_Create ()
 Create a Plank AtomicF object and return an oqaque reference to it.
static PlankResult pl_AtomicF_Init (PlankAtomicFRef p)
 Initialise a Plank AtomicF object.
static PlankResult pl_AtomicF_DeInit (PlankAtomicFRef p)
 Deinitialise a Plank AtomicF object.
PlankResult pl_AtomicF_Destroy (PlankAtomicFRef p)
 Destroy a Plank AtomicF object.
static PlankF pl_AtomicF_Get (PlankAtomicFRef p)
 Get the current value.
static PlankF pl_AtomicF_GetUnchecked (PlankAtomicFRef p)
 Get the current value nonatomically.
PlankUI pl_AtomicF_GetExtra (PlankAtomicFRef p)
 Not used for this class.
PlankUI pl_AtomicF_GetExtraUnchecked (PlankAtomicFRef p)
 Not used for this class.
static PlankF pl_AtomicF_Swap (PlankAtomicFRef p, PlankF newValue)
 Swap the current value with a new value.
static void pl_AtomicF_SwapOther (PlankAtomicFRef p1, PlankAtomicFRef p2)
 Swap over two values.
static void pl_AtomicF_Set (PlankAtomicFRef p, PlankF newValue)
 Set the current value to a new value.
static PlankF pl_AtomicF_Add (PlankAtomicFRef p, PlankF operand)
 Add a value to the current value.
static PlankF pl_AtomicF_Subtract (PlankAtomicFRef p, PlankF operand)
 Subtract a value from the current value.
static PlankF pl_AtomicF_Increment (PlankAtomicFRef p)
 Increment the current value by 1.
static PlankF pl_AtomicF_Decrement (PlankAtomicFRef p)
 Decrement the current value by 1.
static PlankB pl_AtomicF_CompareAndSwap (PlankAtomicFRef p, PlankF oldValue, PlankF newValue)
 Swap the current value with a new value if a specified old value is still the current value.

Detailed Description

Atomic float.

This will be a 32-bit float on all Plank-supported platforms.


Typedef Documentation

typedef struct PlankAtomicF* PlankAtomicFRef

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

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.
static PlankF pl_AtomicF_Decrement ( PlankAtomicFRef  p) [static]

Decrement the current value by 1.

Parameters:
pThe Plank AtomicF object.
Returns:
The new value.
static PlankResult pl_AtomicF_DeInit ( PlankAtomicFRef  p) [inline, static]

Deinitialise a Plank AtomicF object.

Parameters:
pThe Plank AtomicF object.
Returns:
PlankResult_OK if successful, otherwise an error code.
PlankResult pl_AtomicF_Destroy ( PlankAtomicFRef  p)

Destroy a Plank AtomicF object.

Parameters:
pThe Plank AtomicF object.
Returns:
PlankResult_OK if successful, otherwise an error code.
static PlankF pl_AtomicF_Get ( PlankAtomicFRef  p) [static]

Get the current value.

Parameters:
pThe Plank AtomicF object.
Returns:
The value.
PlankUI pl_AtomicF_GetExtra ( PlankAtomicFRef  p)

Not used for this class.

Parameters:
pThe Plank AtomicF object.
Returns:
Always returns 0.
PlankUI pl_AtomicF_GetExtraUnchecked ( PlankAtomicFRef  p)

Not used for this class.

Parameters:
pThe Plank AtomicF object.
Returns:
Always returns 0.
static PlankF pl_AtomicF_GetUnchecked ( PlankAtomicFRef  p) [static]

Get the current value nonatomically.

Parameters:
pThe Plank AtomicF object.
Returns:
The value.
static PlankF pl_AtomicF_Increment ( PlankAtomicFRef  p) [static]

Increment the current value by 1.

Parameters:
pThe Plank AtomicF object.
Returns:
The new value.
static PlankResult pl_AtomicF_Init ( PlankAtomicFRef  p) [inline, static]

Initialise a Plank AtomicF object.

Parameters:
pThe Plank AtomicF object.
Returns:
PlankResult_OK if successful, otherwise an error code.
static void pl_AtomicF_Set ( PlankAtomicFRef  p,
PlankF  newValue 
) [static]

Set the current value to a new value.

Parameters:
pThe Plank AtomicF object.
newValueThe new value to store.
static PlankF pl_AtomicF_Subtract ( PlankAtomicFRef  p,
PlankF  operand 
) [static]

Subtract a value from the current value.

Parameters:
pThe Plank AtomicF object.
operandThe 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:
pThe Plank AtomicF object.
newValueThe new value to store.
Returns:
The previously stored value.
static void pl_AtomicF_SwapOther ( PlankAtomicFRef  p1,
PlankAtomicFRef  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 AtomicF object.
p2The other Plank AtomicF object.
 All Classes Functions Typedefs Enumerations Enumerator Properties