ke/mutex: warden tracking in try_acquire

This commit is contained in:
Loïc Grégoire
2026-10-26 14:41:02 -04:00
parent bdb3f08652
commit 7aaad602ea
+10 -2
View File
@@ -67,12 +67,20 @@ pub const Mutex = struct {
/// Returns true on success.
pub fn try_acquire(self: *Mutex) bool {
const curtd = ke.thread.current();
return self.state.cmpxchgStrong(
if (self.state.cmpxchgStrong(
State.uncontended,
State.from(curtd),
.acquire,
.monotonic,
) == null;
) == null) {
if (config.warden) {
kep.warden.acquired(self, self.wd, .Lock);
}
return true;
}
return false;
}
/// Acquire the lock.