mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-27 13:58:20 +00:00
ke/mutex: warden tracking in try_acquire
This commit is contained in:
+10
-2
@@ -67,12 +67,20 @@ pub const Mutex = struct {
|
|||||||
/// Returns true on success.
|
/// Returns true on success.
|
||||||
pub fn try_acquire(self: *Mutex) bool {
|
pub fn try_acquire(self: *Mutex) bool {
|
||||||
const curtd = ke.thread.current();
|
const curtd = ke.thread.current();
|
||||||
return self.state.cmpxchgStrong(
|
if (self.state.cmpxchgStrong(
|
||||||
State.uncontended,
|
State.uncontended,
|
||||||
State.from(curtd),
|
State.from(curtd),
|
||||||
.acquire,
|
.acquire,
|
||||||
.monotonic,
|
.monotonic,
|
||||||
) == null;
|
) == null) {
|
||||||
|
if (config.warden) {
|
||||||
|
kep.warden.acquired(self, self.wd, .Lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Acquire the lock.
|
/// Acquire the lock.
|
||||||
|
|||||||
Reference in New Issue
Block a user