Open Lighting Architecture
Latest Git
|
Detects if an operation stalls.
The Watchdog can be used to detect when a operation has stalled. When enabled, the Clock() method should be called at regular intervals. While the operation is making forward progress, it should kick the watchdog by calling Kick().
If Kick() isn't called for the specified number of clock cycles, the reset callback will be triggered.
Once a watchdog has fired, it must be Disabled() and Enabled() again to reset it.
This class is thread safe. See also https://en.wikipedia.org/wiki/Watchdog_timer
One way (not recommended) of using this would be:
Public Member Functions | |
Watchdog (unsigned int cycle_limit, Callback0< void > *reset_callback) | |
Create a new Watchdog. More... | |
void | Enable () |
Enable the watchdog. | |
void | Disable () |
Disable the watchdog. | |
void | Kick () |
Kick the watchdog to avoid a reset. More... | |
void | Clock () |
Check if the process has stalled due to a lack of Kick() calls. More... | |
ola::Watchdog::Watchdog | ( | unsigned int | cycle_limit, |
Callback0< void > * | reset_callback | ||
) |
Create a new Watchdog.
cycle_limit | The number of cycles allowed before the reset callback is run. |
reset_callback | the callback to run when the cycle limit is reached. |
void ola::Watchdog::Clock | ( | ) |
Check if the process has stalled due to a lack of Kick() calls.
This should be called regularly. If it's been more than the specified number of clock cycles since a kick, the callback is run.
void ola::Watchdog::Kick | ( | ) |
Kick the watchdog to avoid a reset.
This should be called regularly while the watchdog is enabled.