Mark3 Realtime Kernel
Mark3::Atomic Namespace Reference

The Atomic namespace This utility module provides primatives for atomic operations - that is, operations that are guaranteed to execute uninterrupted. Basic atomic primatives provided here include Set/Add/Subtract, as well as an atomic test-and-set. More...

Functions

template<typename T >
Set (T *pSource_, T val_)
 Set Set a variable to a given value in an uninterruptable operation. More...
 
template<typename T >
Add (T *pSource_, T val_)
 Add Add a value to a variable in an uninterruptable operation. More...
 
template<typename T >
Sub (T *pSource_, T val_)
 Sub Subtract a value from a variable in an uninterruptable operation. More...
 
bool TestAndSet (bool *pbLock)
 TestAndSet Test to see if a variable is set, and set it if is not already set. This is an uninterruptable operation. More...
 

Detailed Description

The Atomic namespace This utility module provides primatives for atomic operations - that is, operations that are guaranteed to execute uninterrupted. Basic atomic primatives provided here include Set/Add/Subtract, as well as an atomic test-and-set.

Function Documentation

◆ Add()

template<typename T >
T Mark3::Atomic::Add ( T *  pSource_,
val_ 
)

Add Add a value to a variable in an uninterruptable operation.

Parameters
pSource_Pointer to a variable
val_Value to add to the variable
Returns
Previously-held value in pSource_

Definition at line 64 of file atomic.h.

◆ Set()

template<typename T >
T Mark3::Atomic::Set ( T *  pSource_,
val_ 
)

Set Set a variable to a given value in an uninterruptable operation.

Parameters
pSource_Pointer to a variable to set the value of
val_New value to set in the variable
Returns
Previously-set value

Definition at line 47 of file atomic.h.

◆ Sub()

template<typename T >
T Mark3::Atomic::Sub ( T *  pSource_,
val_ 
)

Sub Subtract a value from a variable in an uninterruptable operation.

Parameters
pSource_Pointer to a variable
val_Value to subtract from the variable
Returns
Previously-held value in pSource_

Definition at line 81 of file atomic.h.

◆ TestAndSet()

bool Mark3::Atomic::TestAndSet ( bool *  pbLock)

TestAndSet Test to see if a variable is set, and set it if is not already set. This is an uninterruptable operation.

If the value is false, set the variable to true, and return the previously-held value.

If the value is already true, return true.

Parameters
pbLockPointer to a value to test against. This will always be set to "true" at the end of a call to TestAndSet.
Returns
true - Lock value was "true" on entry, false - Lock was set

Definition at line 26 of file atomic.cpp.