Skip to main content

Module deadlock

Module deadlock 

Source
Expand description

Timeout-based deadlock detection helpers.

try_lock_with_timeout wraps an async lock acquisition with a hard deadline. If the lock cannot be acquired in time, the result is Verdict::Fail with a deadlock_suspected tag.

§What this catches

  • Real deadlock cycles (lock A waits for B, B waits for A).
  • Single-lock starvation (one holder never releases).
  • Long contention periods that look like deadlocks from the caller’s perspective.

§What this does NOT catch

Timeout-based detection cannot distinguish a true deadlock from a slow-but-eventually-completing operation. For deterministic cycle detection you’d need a lock-graph tracker, which is out of scope for 0.x.

Functions§

try_mutex_lock_with_timeout
Acquire a tokio::sync::Mutex lock or fail with a deadlock-suspected verdict.
try_rwlock_read_with_timeout
Acquire a tokio::sync::RwLock read lock or fail.
try_rwlock_write_with_timeout
Acquire a tokio::sync::RwLock write lock or fail.