Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
|
Implements a thread-safe watchdog. More...
#include <scheduler.h>
Public Member Functions | |
Watchdog (const std::string &name, std::chrono::milliseconds duration, const std::function< void()> &callback, bool keepCallingOnDeath=false) | |
Construct a new Watchdog. | |
Watchdog (std::chrono::milliseconds duration, const std::function< void()> &callback, bool keepCallingOnDeath=false) | |
Construct a new Watchdog. | |
Watchdog (const Watchdog &)=delete | |
Watchdog & | operator= (const Watchdog &)=delete |
void | feed () |
Feed the watchdog. | |
Friends | |
void | util::impl::notifyScheduler (Watchdog &) |
Implements a thread-safe watchdog.
A watchdog is a timer that is periodically reset (fed) by the client code. If the client fails to feed the watchdog for some duration, then the watchdog is "starved", and the callback is invoked. This is useful for implementing things such as heartbeats.
Clock | The clock to use for timing. |
|
inline |
Construct a new Watchdog.
name | The name of this Watchdog, for logging purposes. |
duration | The timeout duration. If not fed for at least this long, then the callback is invoked. |
callback | The callback to invoke when the watchdog starves. |
keepCallingOnDeath | If true, keep invoking callback every duration milliseconds until fed again. Otherwise, only call callback when starved, and do not call again until being reset and subsequently starved again. |
|
inline |
Construct a new Watchdog.
duration | The timeout duration. If not fed for at least this long, then the callback is invoked. |
callback | The callback to invoke when the watchdog starves. |
keepCallingOnDeath | If true, keep invoking callback every duration milliseconds until fed again. Otherwise, only call callback when starved, and do not call again until being reset and subsequently starved again. |
|
inline |
Feed the watchdog.
Call at least once per period, or the watchdog starves.