| author | |
| committer | |
| log | b4d134a0d2ee238cab70f1e967b2172edbec1b41 |
| tree | a9ca53d8422c30028bc2f8d0724d4fce199e1962 |
| parent | e938344100da959308aa27dee1295e5ce02efc30 |
| parent | 1f78e34de08bb1fdaa93291334bd86a4c8b2825d |
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31608
Reviewed-by: Alex Rønne Petersen <alex@alexrp.com>2 files changed, 3 insertions(+), 22 deletions(-)
lib/std/Io/Threaded.zig+1-20| ... | ... | @@ -1337,25 +1337,6 @@ const Thread = struct { |
| 1337 | 1337 | return @ptrFromInt(@as(usize, @bitCast(split))); |
| 1338 | 1338 | } |
| 1339 | 1339 | }; |
| 1340 | ||
| 1341 | /// Same as `Io.Mutex.lock` but avoids the VTable. | |
| 1342 | fn mutexLock(m: *Io.Mutex) Io.Cancelable!void { | |
| 1343 | const initial_state = m.state.cmpxchgWeak( | |
| 1344 | .unlocked, | |
| 1345 | .locked_once, | |
| 1346 | .acquire, | |
| 1347 | .monotonic, | |
| 1348 | ) orelse { | |
| 1349 | @branchHint(.likely); | |
| 1350 | return; | |
| 1351 | }; | |
| 1352 | if (initial_state == .contended) { | |
| 1353 | try Thread.futexWait(@ptrCast(&m.state.raw), @intFromEnum(Io.Mutex.State.contended), null); | |
| 1354 | } | |
| 1355 | while (m.state.swap(.contended, .acquire) != .unlocked) { | |
| 1356 | try Thread.futexWait(@ptrCast(&m.state.raw), @intFromEnum(Io.Mutex.State.contended), null); | |
| 1357 | } | |
| 1358 | } | |
| 1359 | 1340 | }; |
| 1360 | 1341 | |
| 1361 | 1342 | const Syscall = struct { |
| ... | ... | @@ -18663,7 +18644,7 @@ fn condWait(cond: *Io.Condition, mutex: *Io.Mutex) void { |
| 18663 | 18644 | |
| 18664 | 18645 | /// Same as `Io.Mutex.lockUncancelable` but avoids the VTable. |
| 18665 | 18646 | pub fn mutexLock(m: *Io.Mutex) void { |
| 18666 | const initial_state = m.state.cmpxchgWeak( | |
| 18647 | const initial_state = m.state.cmpxchgStrong( | |
| 18667 | 18648 | .unlocked, |
| 18668 | 18649 | .locked_once, |
| 18669 | 18650 | .acquire, |
lib/std/Progress.zig+2-2| ... | ... | @@ -450,7 +450,7 @@ pub const Node = struct { |
| 450 | 450 | const ipc = @atomicLoad(Ipc, ipc_ptr, .monotonic); |
| 451 | 451 | if (ipc.locked or ipc.valid) continue; |
| 452 | 452 | const generation = ipc.generation +% 1; |
| 453 | if (@cmpxchgWeak( | |
| 453 | if (@cmpxchgStrong( | |
| 454 | 454 | Ipc, |
| 455 | 455 | ipc_ptr, |
| 456 | 456 | ipc, |
| ... | ... | @@ -1133,7 +1133,7 @@ fn serialize(io: Io, serialized_buffer: *Serialized.Buffer) !Serialized { |
| 1133 | 1133 | const ipc_data = &serialized_buffer.ipc_data[ipc_index.slot]; |
| 1134 | 1134 | state: switch (ipc_data.state) { |
| 1135 | 1135 | .unused => { |
| 1136 | if (@cmpxchgWeak( | |
| 1136 | if (@cmpxchgStrong( | |
| 1137 | 1137 | Ipc, |
| 1138 | 1138 | ipc, |
| 1139 | 1139 | .{ .locked = false, .valid = true, .generation = ipc_index.generation }, |