This is a software based watchdog.

It fires the onTimeout event when a specified amount of time has passed before it was reset.

At the beginning the watchdog is not enabled. You have to call enable() in order for it to work. If you change the timeout after the watchdag was enabled the new timeout will be used only after the next restart call.

Future improvement: Just using setTimeout has the drawback, that if the main event loop gets stuck e.g. in the I/O phase, then the timeout won't fire until it is unstuck. This can be improved, by also scheduling a check in the I/O phase and the Immediate phase of the event loop. But this would require more resources and would make the code much more complex.

Constructors

Properties

Methods

Constructors

Properties

onTimeout: OEvent<(() => void)> = ...
timeout: number

Methods

  • Disable the watchdog.

    It never throws.

    Returns void

  • Enable the watchdog.

    Returns void

    Error - If watchdog is already enabled.

  • Restart the timout, thus preventing the onTimeout event for another this.timeout msecs.

    Returns void