Embedded Multicore Building Blocks V1.0.0
|
Class representing atomic variables. More...
#include <atomic.h>
Public Member Functions | |
Atomic () | |
Default constructor. More... | |
Atomic (BaseType val) | |
Valued-based constructor. More... | |
BaseType | operator= (BaseType val) |
Assignment operator. More... | |
operator BaseType () const | |
Type conversion. More... | |
bool | IsArithmetic () const |
Predicate representing support for arithmetic operations. More... | |
bool | IsInteger () const |
Predicate representing integers. More... | |
bool | IsPointer () const |
Predicate representing pointers. More... | |
void | Store (BaseType val) |
Store operation. More... | |
BaseType | Load () const |
Load operation. More... | |
BaseType | Swap (BaseType val) |
Swap operation. More... | |
bool | CompareAndSwap (BaseType &expected, BaseType desired) |
Compare-and-Swap operation (CAS). More... | |
Arithmetic members | |
The following members are only available if | |
BaseType | FetchAndAdd (BaseType val) |
Fetch-and-Add operation. More... | |
BaseType | FetchAndSub (BaseType val) |
Fetch-and-Sub operation. More... | |
BaseType | operator++ (int) |
Post-increment operation. More... | |
BaseType | operator-- (int) |
Post-decrement operation. More... | |
BaseType | operator++ () |
Pre-increment operation. More... | |
BaseType | operator-- () |
Pre-decrement operation. More... | |
BaseType | operator+= (BaseType val) |
Assignment by sum operation. More... | |
BaseType | operator-= (BaseType val) |
Assignment by difference operation. More... | |
Integer members | |
The following members are only available if | |
void | operator&= (BaseType val) |
Assignment by bitwise AND. More... | |
void | operator|= (BaseType val) |
Assignment by bitwise OR. More... | |
void | operator^= (BaseType val) |
Assignment by bitwise XOR. More... | |
Pointer members | |
The following members are only available if | |
BaseType * | operator-> () |
Structure dereference operation. More... | |
BaseType & | operator* () |
Dereference operation. More... | |
Class representing atomic variables.
The current implementation guarantees sequential consistency (full fences) for all atomic operations. Relaxed memory models may be added in the future.
BaseType | Underlying type |
embb::base::Atomic< BaseType >::Atomic | ( | ) |
Default constructor.
Constructs an atomic variable holding zero.
|
explicit |
Valued-based constructor.
Constructs an atomic variable holding the passed value.
val | Initial value |
BaseType embb::base::Atomic< BaseType >::operator= | ( | BaseType | val | ) |
Assignment operator.
Assigns the passed value to the object.
val | The value to assign |
embb::base::Atomic< BaseType >::operator BaseType | ( | ) | const |
bool embb::base::Atomic< BaseType >::IsArithmetic | ( | ) | const |
Predicate representing support for arithmetic operations.
Returns true
if type BaseType
supports arithmetic operations, otherwise false
. Only integers and non-void pointers support arithmetic operations.
bool embb::base::Atomic< BaseType >::IsInteger | ( | ) | const |
Predicate representing integers.
Returns true
if BaseType
is an integer type, otherwise false
.
BaseType
is an integerbool embb::base::Atomic< BaseType >::IsPointer | ( | ) | const |
Predicate representing pointers.
Returns true
if BaseType
is a non-void pointer type, otherwise false
.
BaseType
is a non-void pointer typevoid embb::base::Atomic< BaseType >::Store | ( | BaseType | val | ) |
Store operation.
Stores the passed value in the object. Equivalent to assignment operator, except that Store
does not return anything.
val | Value to be stored |
BaseType embb::base::Atomic< BaseType >::Load | ( | ) | const |
Load operation.
Loads and returns the stored value. Equivalent to type conversion.
BaseType embb::base::Atomic< BaseType >::Swap | ( | BaseType | val | ) |
Swap operation.
Stores the given value in the object and returns the old value.
val | New value |
bool embb::base::Atomic< BaseType >::CompareAndSwap | ( | BaseType & | expected, |
BaseType | desired | ||
) |
Compare-and-Swap operation (CAS).
Stores desired
if the current value is equal to expected
. Otherwise, stores the current value in expected
.
expected | Expected value |
desired | Desired value |
true
if CAS succeeded, otherwise false
BaseType embb::base::Atomic< BaseType >::FetchAndAdd | ( | BaseType | val | ) |
Fetch-and-Add operation.
Adds the passed value and returns the old value.
val | Addend |
BaseType embb::base::Atomic< BaseType >::FetchAndSub | ( | BaseType | val | ) |
Fetch-and-Sub operation.
Subtracts the passed value and returns the old value.
val | Subtrahend |
BaseType embb::base::Atomic< BaseType >::operator++ | ( | int | ) |
Post-increment operation.
Increments the value and returns the old value.
BaseType embb::base::Atomic< BaseType >::operator-- | ( | int | ) |
Post-decrement operation.
Decrements the value and returns the old value.
BaseType embb::base::Atomic< BaseType >::operator++ | ( | ) |
Pre-increment operation.
Increments the value and returns the new value.
BaseType embb::base::Atomic< BaseType >::operator-- | ( | ) |
Pre-decrement operation.
Decrements the value and returns the new value.
BaseType embb::base::Atomic< BaseType >::operator+= | ( | BaseType | val | ) |
Assignment by sum operation.
Adds the passed value and returns the new value.
val | Addend |
BaseType embb::base::Atomic< BaseType >::operator-= | ( | BaseType | val | ) |
Assignment by difference operation.
Subtracts the passed value and returns the new value.
val | Subtrahend |
void embb::base::Atomic< BaseType >::operator&= | ( | BaseType | val | ) |
Assignment by bitwise AND.
Stores the result of the bitwise AND in the current object. Does not return anything, since this cannot be implemented atomically on all architectures.
val | Second operand of bitwise AND |
void embb::base::Atomic< BaseType >::operator|= | ( | BaseType | val | ) |
Assignment by bitwise OR.
Stores the result of the bitwise OR in the current object. Does not return anything, since this cannot be implemented atomically on all architectures.
val | Second operand of bitwise OR |
void embb::base::Atomic< BaseType >::operator^= | ( | BaseType | val | ) |
Assignment by bitwise XOR.
Stores the result of the bitwise XOR in the current object. Does not return anything, since this cannot be implemented atomically on all architectures.
val | Second operand of bitwise XOR |
BaseType* embb::base::Atomic< BaseType >::operator-> | ( | ) |
Structure dereference operation.
Used to access an element of an instance of a class or a structure pointed to by the stored pointer.
BaseType& embb::base::Atomic< BaseType >::operator* | ( | ) |
Dereference operation.
Used to access the object pointed to by the stored pointer.