Skip to main content

nano_watchdog/
lib.rs

1//! OS-thread watchdog for stuck task detection with RAII guards.
2//!
3//! `nano-watchdog` runs on a dedicated OS thread — not Tokio — so it
4//! can detect deadlocks even when the async runtime is frozen.
5//!
6//! # Quick Start
7//!
8//! ```rust
9//! use nano_watchdog::{TaskTracker, WatchdogConfig, start_watchdog};
10//!
11//! // Create a tracker (typically stored in a static)
12//! let tracker = Box::leak(Box::new(TaskTracker::new()));
13//!
14//! // Start the watchdog thread
15//! start_watchdog(tracker, WatchdogConfig::default(), None);
16//!
17//! // Track tasks with RAII guards
18//! let guard = tracker.track("processing request");
19//! guard.set_phase("parsing");
20//! // ... do work ...
21//! guard.set_phase("responding");
22//! // guard dropped — task automatically unregistered
23//! ```
24
25mod tracker;
26mod watchdog;
27
28pub use tracker::{TaskTracker, TaskGuard, StuckTaskInfo};
29pub use watchdog::{WatchdogConfig, OnStuckCallback, start_watchdog};