Skip to main content

Crate nano_watchdog

Crate nano_watchdog 

Source
Expand description

OS-thread watchdog for stuck task detection with RAII guards.

nano-watchdog runs on a dedicated OS thread — not Tokio — so it can detect deadlocks even when the async runtime is frozen.

§Quick Start

use nano_watchdog::{TaskTracker, WatchdogConfig, start_watchdog};

// Create a tracker (typically stored in a static)
let tracker = Box::leak(Box::new(TaskTracker::new()));

// Start the watchdog thread
start_watchdog(tracker, WatchdogConfig::default(), None);

// Track tasks with RAII guards
let guard = tracker.track("processing request");
guard.set_phase("parsing");
// ... do work ...
guard.set_phase("responding");
// guard dropped — task automatically unregistered

Structs§

StuckTaskInfo
Information about a task that has exceeded the stuck threshold.
TaskGuard
RAII guard that tracks a task’s lifetime.
TaskTracker
Tracks active tasks for deadlock detection.
WatchdogConfig
Configuration for the watchdog loop.

Functions§

start_watchdog
Start the watchdog on a dedicated OS thread.

Type Aliases§

OnStuckCallback
Callback type for stuck task notifications.