MIRA
Functions
mira::atomic Namespace Reference

Functions

uint32 inc (volatile uint32 *var)
 Increments the value of the variable pointed to by var and returns its old value. More...
 
uint32 dec (volatile uint32 *var)
 Decrements the value of the variable pointed to by var and returns its old value. More...
 
void write (volatile uint32 *var, uint32 value)
 Sets the value of the variable pointed to by var in an atomic operation. More...
 
uint32 cas (volatile uint32 *var, uint32 value, uint32 cmp)
 Compare And Swap. More...
 

Function Documentation

◆ inc()

uint32 mira::atomic::inc ( volatile uint32 *  var)
inline

Increments the value of the variable pointed to by var and returns its old value.

This is the atomic equivalent for:

uint32 tmp = *var;
*var++;
return tmp;

◆ dec()

uint32 mira::atomic::dec ( volatile uint32 *  var)
inline

Decrements the value of the variable pointed to by var and returns its old value.

This is the atomic equivalent for:

uint32 tmp = *var;
*var--;
return tmp;

◆ write()

void mira::atomic::write ( volatile uint32 *  var,
uint32  value 
)
inline

Sets the value of the variable pointed to by var in an atomic operation.

◆ cas()

uint32 mira::atomic::cas ( volatile uint32 *  var,
uint32  value,
uint32  cmp 
)
inline

Compare And Swap.

Compare the variable '*var' with 'cmp'. If both values are the same, *var is replaced with 'value'. The old value of *var will be returned.

This is the atomic equivalent for:

uint32 tmp = *var;
if(*var == cmp)
*var = value;
return tmp;