> This page is for version 3.0 (Latest) (default).
> For other versions, use one of these documentation indexes:
> - 3.0 (Latest) (default): https://docs.nvidia.com/holoscan/sensor-bridge/3-0/llms.txt
> - 2.7: https://docs.nvidia.com/holoscan/sensor-bridge/2-7/llms.txt
> - Archives: https://docs.nvidia.com/holoscan/sensor-bridge/archives/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sensor-bridge/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/holoscan/sensor-bridge/_mcp/server.

# hololink::module::Watchdog

> Detects when an expected event stops happening.

Detects when an expected event stops happening.

A `Watchdog` is a deadline timer that runs on the [ReactorV1](reactorv1). While it is armed, each call to tap() restarts the countdown. If the countdown reaches zero before the next tap, the `Watchdog` calls its `on_timeout` function once, on the reactor thread, and then waits until it is armed again. Call tap() each time the event being watched occurs (for example, a frame arrives) so that a gap longer than the timeout is reported as a loss.

Every method may be called from any thread. `on_timeout` runs on the reactor thread, with no `Watchdog` lock held, so it may itself call arm(), tap() or cancel(); a typical `on_timeout` re-arms in order to keep watching.

A `Watchdog` cannot be copied.

```cpp showLineNumbers={false}
#include <hololink/module/watchdog.hpp>
```

---

## Constructors

### Watchdog \[#watchdog]

```cpp showLineNumbers={false}
hololink::module::Watchdog::Watchdog(
    std::shared_ptr<ReactorV1> reactor,
    double timeout_s,
    std::function<void()> on_timeout
)
```

Create a `Watchdog`.

It is idle until arm() or tap() is called.

**Parameters**

**`reactor`** `std::shared_ptr<ReactorV1>`

The reactor that supplies the timer and runs `on_timeout`. If null, the `Watchdog` never times out.

---

**`timeout_s`** `double`

Seconds without a tap before `on_timeout` is called. If zero or negative, the `Watchdog` is disabled and never times out.

---

**`on_timeout`** `std::function<void()>`

Function to call when the timeout elapses. It must remain valid for as long as a timeout can still occur, so if it refers to an object that is to be destroyed, call cancel() (or destroy the `Watchdog`) first.

---

### Destructor \[#destructor]

### \~Watchdog

```cpp showLineNumbers={false}
hololink::module::Watchdog::~Watchdog()
```

Cancel any pending timeout and destroy the `Watchdog`.

No timeout starts after this returns. A call to `on_timeout` that is already running on the reactor thread is not waited for.

---

## Methods

### arm \[#arm]

```cpp showLineNumbers={false}
void hololink::module::Watchdog::arm()
```

Start watching, or restart the countdown from the full timeout.

Replaces any countdown already in progress. Does nothing if the `Watchdog` has no reactor or is disabled by a timeout of zero or less.

### tap \[#tap]

```cpp showLineNumbers={false}
void hololink::module::Watchdog::tap()
```

Report that the watched event happened.

Restarts the countdown, exactly as arm() does. It also starts watching if the `Watchdog` was idle, including after a timeout or cancel().

If a timeout was about to be delivered at the same moment, this prevents it, so an event arriving right at the deadline does not cause a spurious timeout.

### cancel \[#cancel]

```cpp showLineNumbers={false}
void hololink::module::Watchdog::cancel()
```

Stop watching.

A timeout that has not yet begun is prevented; it is not delivered even if it was about to fire. The `Watchdog` can be started again with arm() or tap(). A call to `on_timeout` that is already running on the reactor thread is not waited for.