Embedded Multicore Building Blocks V1.0.0
Typedefs | Functions
Counter

Thread-safe counter. More...

Typedefs

typedef opaque_type embb_counter_t
 Opaque type representing a thread-safe counter. More...
 

Functions

int embb_counter_init (embb_counter_t *counter)
 Initializes counter and sets it to zero. More...
 
unsigned int embb_counter_get (embb_counter_t *counter)
 Returns the current value of counter. More...
 
unsigned int embb_counter_increment (embb_counter_t *counter)
 Increments counter and returns the old value. More...
 
unsigned int embb_counter_decrement (embb_counter_t *counter)
 Decrements counter and returns the old value. More...
 
void embb_counter_reset (embb_counter_t *counter)
 Resets an initialized counter to 0. More...
 
void embb_counter_destroy (embb_counter_t *counter)
 Destroys an initialized counter. More...
 

Detailed Description

Thread-safe counter.

Typedef Documentation

typedef opaque_type embb_counter_t

Opaque type representing a thread-safe counter.

Function Documentation

int embb_counter_init ( embb_counter_t counter)

Initializes counter and sets it to zero.

Returns
EMBB_SUCCESS if counter could be initialized
EMBB_ERROR otherwise
Concurrency
Thread-safe and wait-free
Parameters
[out]counterPointer to counter
unsigned int embb_counter_get ( embb_counter_t counter)

Returns the current value of counter.

Precondition
counter is not NULL.
Returns
Current value
Concurrency
Thread-safe and wait-free
Parameters
[in]counterPointer to counter
unsigned int embb_counter_increment ( embb_counter_t counter)

Increments counter and returns the old value.

Precondition
counter is not NULL.
Returns
Old, non-incremented value
Concurrency
Thread-safe and wait-free
Parameters
[in,out]counterPointer to counter
unsigned int embb_counter_decrement ( embb_counter_t counter)

Decrements counter and returns the old value.

Precondition
counter is not NULL.
Returns
Old, non-decremented value
Concurrency
Thread-safe and wait-free
Parameters
[in,out]counterPointer to counter
void embb_counter_reset ( embb_counter_t counter)

Resets an initialized counter to 0.

Precondition
counter is initialized and not NULL.
Concurrency
Thread-safe and wait-free
Parameters
[in,out]counterPointer to counter
void embb_counter_destroy ( embb_counter_t counter)

Destroys an initialized counter.

Precondition
counter is initialized and not NULL.
Postcondition
counter is invalid and cannot be used anymore
Concurrency
Thread-safe and wait-free
Parameters
[out]counterPointer to counter