mavtables
0.2.1
MAVLink router and firewall.
|
#include <RecursionGuard.hpp>
Public Member Functions | |
RecursionGuard (RecursionData &data) | |
~RecursionGuard () | |
Guard against recursion.
A recursion guard is an RAII (Resource Acquisition Is Initialization) data structure used to raise an error upon recursion. The constructor marks a RecursionData structure, acquiring ownership of the containing function (within the given thread). Recursion guards treat calls from different threads separately, therefore, it will not guard against re-entrantcy.
An example of how to use this is:
If b_function
, or any function it calls, ever calls a_function
then this will throw RecursionError. However, if multiple threads call a_function
(possibly at the same time) but b_function
does not call a_function
then no error will be thrown.
Definition at line 60 of file RecursionGuard.hpp.
RecursionGuard::RecursionGuard | ( | RecursionData & | data | ) |
Construct a RecursionGuard.
This marks the given RecursionData structure, ensuring it cannot be used to construct another guard without raising a RecursionError.
data | The object used to prevent recursion. |
RecursionError | if the given data structure has already been marked by a RecursionGuard instance that is still in scope. |
Definition at line 35 of file RecursionGuard.cpp.
References mavlink::id().
RecursionGuard::~RecursionGuard | ( | ) |
Release the lock on the contain RecursionData.
This allows the function to be called again without error.
Definition at line 52 of file RecursionGuard.cpp.