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