Concurrency

Detailed Description

The classes and functions in this group make it possible to write multi-threaded programs. Access to shared resources can be serialized by various types of mutexes, semaphores and condition variables. The most lightweight synchronization primitives are atomic integers. The framework allows to start threads, which can be either joinable or detached.

Classes

class  atomic_t
 Atomic integers to be used with atomicity functions. More...
 

Functions

int atomicCompareExchange (volatile atomic_t &val, int exch, int comp)
 Performs an atomic compare-and-exchange operation. More...
 
void * atomicCompareExchange (void *volatile &val, void *exch, void *comp)
 Performs an atomic compare-and-exchange operation. More...
 
int atomicDecrement (volatile atomic_t &val)
 Decreases a value by one as an atomic operation. More...
 
int atomicExchange (volatile atomic_t &val, int exch)
 Performs an atomic exchange operation. More...
 
void * atomicExchange (void *volatile &val, void *exch)
 Performs an atomic exchange operation. More...
 
int atomicExchangeAdd (volatile atomic_t &val, int add)
 Performs atomic addition of two values. More...
 
int atomicGet (volatile atomic_t &val)
 Atomically get a value. More...
 
int atomicIncrement (volatile atomic_t &val)
 Increases a value by one as an atomic operation. More...
 
void atomicSet (volatile atomic_t &val, int n)
 Atomically set a value. More...
 

Function Documentation

int atomicGet ( volatile atomic_t val)
related

Returns the value and employs a memory fence after the get. Acquire semantics prevent memory reordering with any read or write operation which follows it in program order.

void atomicSet ( volatile atomic_t val,
int  n 
)
related

Sets the value and employs a memory fence before the set. Release semantics prevent memory reordering with any read or write operation which precedes it in program order.

int atomicIncrement ( volatile atomic_t val)
related

Returns the resulting incremented value.

int atomicDecrement ( volatile atomic_t val)
related

Returns the resulting decremented value.

int atomicExchange ( volatile atomic_t val,
int  exch 
)
related

Sets val to exch and returns the initial value of val.

int atomicCompareExchange ( volatile atomic_t val,
int  exch,
int  comp 
)
related

If val is equal to comp, val is replaced by exch. The initial value of of val is returned.

int atomicExchangeAdd ( volatile atomic_t val,
int  add 
)
related

Returns the initial value of the addend.

void * atomicExchange ( void *volatile &  val,
void *  exch 
)
related

Sets val to exch and returns the initial value of val.

void * atomicCompareExchange ( void *volatile &  val,
void *  exch,
void *  comp 
)
related

If val is equal to comp, val is replaced by exch. The initial value of ptr is returned.