diff --git a/lib/std/Io.zig b/lib/std/Io.zig index c287115db85ed412cccfd31f60805454c24a2373..cf23796db229468258dd82d06fd66c7690abdd83 100644 --- a/lib/std/Io.zig +++ b/lib/std/Io.zig @@ -1348,7 +1348,13 @@ pub fn futexWake(io: Io, comptime T: type, ptr: *align(@alignOf(u32)) const T, m return io.vtable.futexWake(io.userdata, @ptrCast(ptr), max_waiters); } -pub const Mutex = struct { +/// 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. Having a guaranteed memory layout including mutexes is +/// important for IPC over shared memory (mmap). +pub const Mutex = extern struct { state: std.atomic.Value(State), pub const init: Mutex = .{ .state = .init(.unlocked) };