diff --git a/lib/std/Io.zig b/lib/std/Io.zig index 9bd7ec5a0dc76ed8628b7a9933b7c1bf41203ec3..3924d8ca00f44db50cec2301add1fedf7573195c 100644 --- a/lib/std/Io.zig +++ b/lib/std/Io.zig @@ -1740,9 +1740,11 @@ pub fn futexWake(io: Io, comptime T: type, ptr: *align(@alignOf(u32)) const T, m /// Mutex is a synchronization primitive which enforces atomic access to a /// shared region of code known as the "critical section". /// -/// Mutex is an extern struct so that it may be used as a field inside another -/// extern struct. -pub const Mutex = extern struct { +/// Mutex is not an extern struct because locking and unlocking go through the +/// futex calls of `Io`, which are not required to work across processes or +/// compilation units. Code that needs a fixed layout can build its own lock on +/// a `u32` with the same futex calls. +pub const Mutex = struct { state: std.atomic.Value(State), pub const init: Mutex = .{ .state = .init(.unlocked) };