struct SafetyLock [src]

Fields

state: State = if (runtime_safety) .unlocked else .unknown

Members

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); } }