A guard that is used to make sure that programs do not get stuck.
More...
#include <Radiant/WatchDog.hpp>
A guard that is used to make sure that programs do not get stuck.
If the program appears to be stuck (not calling hostIsAlive for given time) then this class simply shuts down the application.
| long Radiant::WatchDog::addListener |
( |
std::function< void()> |
callback | ) |
|
Add a listener that is called just before the watchdog is shutting down the process.
- Returns
- listener id
| void Radiant::WatchDog::forgetHost |
( |
void * |
key | ) |
|
Instructs the Watchdog to forget some hosting object.
- Parameters
-
| key | The identifier of the calling object. |
| void Radiant::WatchDog::hostIsAlive |
( |
void * |
key | ) |
|
Inform the watchdog that the host application is working.
You can call this function at any time, and the call is fully thread-safe. After calling this method for the first time, you need to keep calling it periodically, to make sure that the watchdog knows you are there.
- Parameters
-
| key | The identifier of the calling object. This is usually a point to some object which provides a handy way of generating unique keys in C/C++. |
| static bool Radiant::WatchDog::isEnabled |
( |
| ) |
|
|
static |
Is the watchdog disabled by the user.
- Returns
- true if watchdog is enabled
- See Also
- setEnabled
| bool Radiant::WatchDog::paused |
( |
| ) |
const |
|
inline |
Check if the watchdog is paused.
- Returns
- true if paused; otherwise false
| void Radiant::WatchDog::removeListener |
( |
long |
id | ) |
|
Remove listener.
- Parameters
-
| static void Radiant::WatchDog::setEnabled |
( |
bool |
enabled | ) |
|
|
static |
Enable or disable the watchdog.
This function only sets the flag if the watchdog should be used. It is up to the user the check the flag.
- Parameters
-
| enabled | should the watchdog be enabled? |
- See Also
- isEnabled
| void Radiant::WatchDog::setInterval |
( |
float |
seconds | ) |
|
|
inline |
Sets the interval for checking if the host is alive.
- Parameters
-
| seconds | Length of the interval in seconds |
| void Radiant::WatchDog::stop |
( |
| ) |
|