struct SafetyLock [src]
Fields
state: State = if (runtime_safety) .unlocked else .unknown
Members
- assertLocked (Function)
- assertUnlocked (Function)
- lock (Function)
- State (Type)
- unlock (Function)
Source
pub const SafetyLock = struct {
state: State = if (runtime_safety) .unlocked else .unknown,
pub const State = if (runtime_safety) enum { unlocked, locked } else enum { unknown };
pub fn lock(l: *SafetyLock) void {
if (!runtime_safety) return;
assert(l.state == .unlocked);
l.state = .locked;
}
pub fn unlock(l: *SafetyLock) void {
if (!runtime_safety) return;
assert(l.state == .locked);
l.state = .unlocked;
}
pub fn assertUnlocked(l: SafetyLock) void {
if (!runtime_safety) return;
assert(l.state == .unlocked);
}
pub fn assertLocked(l: SafetyLock) void {
if (!runtime_safety) return;
assert(l.state == .locked);
}
}