MCPcopy Create free account
hub / github.com/CodeSentryAI/lockbud / deadlock_with

Method deadlock_with

src/interest/concurrency/lock.rs:154–180  ·  view source on GitHub ↗

In parking_lot, the read lock is by default non-recursive if not specified. if two recursively acquired read locks in one thread are interleaved by a write lock from another thread, a deadlock may happen. The reason is write lock has higher priority than read lock in parking_lot. In std::sync, the implementation of read lock depends on the underlying OS. AFAIK, the implementation on Windows and Ma

(&self, other: &Self)

Source from the content-addressed store, hash-verified

152 /// spin explicitly documents no write priority. So the read lock in spin can
153 /// be acquired recursively.
154 pub fn deadlock_with(&self, other: &Self) -> DeadlockPossibility {
155 use LockGuardTy::*;
156 match (self, other) {
157 (StdMutex(a), StdMutex(b))
158 | (ParkingLotMutex(a), ParkingLotMutex(b))
159 | (SpinMutex(a), SpinMutex(b))
160 | (StdRwLockWrite(a), StdRwLockWrite(b))
161 | (StdRwLockWrite(a), StdRwLockRead(b))
162 | (StdRwLockRead(a), StdRwLockWrite(b))
163 | (ParkingLotWrite(a), ParkingLotWrite(b))
164 | (ParkingLotWrite(a), ParkingLotRead(b))
165 | (ParkingLotRead(a), ParkingLotWrite(b))
166 | (SpinWrite(a), SpinWrite(b))
167 | (SpinWrite(a), SpinRead(b))
168 | (SpinRead(a), SpinWrite(b))
169 if a == b =>
170 {
171 DeadlockPossibility::Probably
172 }
173 (StdRwLockRead(a), StdRwLockRead(b)) | (ParkingLotRead(a), ParkingLotRead(b))
174 if a == b =>
175 {
176 DeadlockPossibility::Possibly
177 }
178 _ => DeadlockPossibility::Unlikely,
179 }
180 }
181}
182
183/// The lockguard info. `span` is for report.

Callers 1

deadlock_possibilityFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected