pub struct DeadlockDetector { /* private fields */ }Expand description
Deadlock detector. Deadlock detector using wait-for graphs.
Uses std::sync::Mutex (not tokio::sync::Mutex) because:
- Locks are never held across
.awaitpoints - Critical sections are sub-microsecond (single HashMap operations)
tokio::sync::Mutexwould add unnecessary overhead for these short operations
Implementations§
Source§impl DeadlockDetector
impl DeadlockDetector
Sourcepub fn new(config: DeadlockDetectorConfig) -> Self
pub fn new(config: DeadlockDetectorConfig) -> Self
Create a new deadlock detector.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create with default configuration.
Sourcepub fn config(&self) -> &DeadlockDetectorConfig
pub fn config(&self) -> &DeadlockDetectorConfig
Get the configuration.
Sourcepub fn register_lock(&self, lock_type: LockType) -> u64
pub fn register_lock(&self, lock_type: LockType) -> u64
Register a new lock.
Sourcepub fn unregister_lock(&self, lock_id: u64)
pub fn unregister_lock(&self, lock_id: u64)
Unregister a lock.
Sourcepub fn record_acquire(&self, lock_id: u64, thread_id: u64)
pub fn record_acquire(&self, lock_id: u64, thread_id: u64)
Record lock acquisition.
Sourcepub fn record_release(&self, lock_id: u64)
pub fn record_release(&self, lock_id: u64)
Record lock release.
Sourcepub fn record_wait(&self, lock_id: u64, thread_id: u64)
pub fn record_wait(&self, lock_id: u64, thread_id: u64)
Record a wait for lock.
Sourcepub fn detect_deadlock(&self) -> Option<Vec<u64>>
pub fn detect_deadlock(&self) -> Option<Vec<u64>>
Detect deadlocks using cycle detection in wait graph.
Sourcepub fn check_long_held(&self) -> Vec<(u64, Duration)>
pub fn check_long_held(&self) -> Vec<(u64, Duration)>
Check for long-held locks.
Sourcepub fn register_request(&self, request_id: &str, thread_id: u64)
pub fn register_request(&self, request_id: &str, thread_id: u64)
Register a request for tracking.
Sourcepub fn unregister_request(&self, request_id: &str)
pub fn unregister_request(&self, request_id: &str)
Unregister a request.
Sourcepub fn tracked_count(&self) -> usize
pub fn tracked_count(&self) -> usize
Get number of tracked requests.
Sourcepub fn get_lock_info(&self, lock_id: u64) -> Option<LockInfo>
pub fn get_lock_info(&self, lock_id: u64) -> Option<LockInfo>
Get lock info.
Sourcepub fn lock_count(&self) -> usize
pub fn lock_count(&self) -> usize
Get total number of registered locks.
Auto Trait Implementations§
impl !Freeze for DeadlockDetector
impl RefUnwindSafe for DeadlockDetector
impl Send for DeadlockDetector
impl Sync for DeadlockDetector
impl Unpin for DeadlockDetector
impl UnsafeUnpin for DeadlockDetector
impl UnwindSafe for DeadlockDetector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more