| ... | ... | @@ -66,7 +66,7 @@ pub fn wait(ptr: *const Atomic(u32), expect: u32, timeout: ?u64) error{TimedOut} |
| 66 | 66 | pub fn wake(ptr: *const Atomic(u32), num_waiters: u32) void { |
| 67 | 67 | if (single_threaded) return; |
| 68 | 68 | if (num_waiters == 0) return; |
| 69 | | |
| 69 | |
| 70 | 70 | return OsFutex.wake(ptr, num_waiters); |
| 71 | 71 | } |
| 72 | 72 | |
| ... | ... | @@ -83,11 +83,11 @@ else |
| 83 | 83 | |
| 84 | 84 | const UnsupportedFutex = struct { |
| 85 | 85 | fn wait(ptr: *const Atomic(u32), expect: u32, timeout: ?u64) error{TimedOut}!void { |
| 86 | | return unsupported(.{ptr, expect, timeout}); |
| 86 | return unsupported(.{ ptr, expect, timeout }); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | fn wake(ptr: *const Atomic(u32), num_waiters: u32) void { |
| 90 | | return unsupported(.{ptr, num_waiters}); |
| 90 | return unsupported(.{ ptr, num_waiters }); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | fn unsupported(unused: anytype) noreturn { |
| ... | ... | @@ -417,7 +417,6 @@ test "Futex - Signal" { |
| 417 | 417 | fn run(self: *@This(), hit_to: *@This()) !void { |
| 418 | 418 | var iterations: usize = 4; |
| 419 | 419 | while (iterations > 0) : (iterations -= 1) { |
| 420 | | |
| 421 | 420 | var value: u32 = undefined; |
| 422 | 421 | while (true) { |
| 423 | 422 | value = self.value.load(.Acquire); |
| ... | ... | @@ -427,7 +426,7 @@ test "Futex - Signal" { |
| 427 | 426 | |
| 428 | 427 | try testing.expectEqual(value, self.current + 1); |
| 429 | 428 | self.current = value; |
| 430 | | |
| 429 | |
| 431 | 430 | _ = hit_to.value.fetchAdd(1, .Release); |
| 432 | 431 | Futex.wake(&hit_to.value, 1); |
| 433 | 432 | } |
| ... | ... | @@ -437,10 +436,10 @@ test "Futex - Signal" { |
| 437 | 436 | var ping = Paddle{}; |
| 438 | 437 | var pong = Paddle{}; |
| 439 | 438 | |
| 440 | | const t1 = try std.Thread.spawn(.{}, Paddle.run, .{&ping, &pong}); |
| 439 | const t1 = try std.Thread.spawn(.{}, Paddle.run, .{ &ping, &pong }); |
| 441 | 440 | defer t1.join(); |
| 442 | 441 | |
| 443 | | const t2 = try std.Thread.spawn(.{}, Paddle.run, .{&pong, &ping}); |
| 442 | const t2 = try std.Thread.spawn(.{}, Paddle.run, .{ &pong, &ping }); |
| 444 | 443 | defer t2.join(); |
| 445 | 444 | |
| 446 | 445 | _ = ping.value.fetchAdd(1, .Release); |
| ... | ... | @@ -497,7 +496,7 @@ test "Futex - Broadcast" { |
| 497 | 496 | |
| 498 | 497 | // Try to wait for the threads to start before running runSender(). |
| 499 | 498 | // NOTE: not actually needed for correctness. |
| 500 | | std.time.sleep(16 * std.time.ns_per_ms); |
| 499 | std.time.sleep(16 * std.time.ns_per_ms); |
| 501 | 500 | try ctx.runSender(); |
| 502 | 501 | |
| 503 | 502 | const notified = ctx.notified.load(.Monotonic); |
| ... | ... | @@ -551,7 +550,7 @@ test "Futex - Chain" { |
| 551 | 550 | var ctx = Context{}; |
| 552 | 551 | for (ctx.threads) |*entry, index| { |
| 553 | 552 | entry.signal = .{}; |
| 554 | | entry.thread = try std.Thread.spawn(.{}, Context.run, .{&ctx, index}); |
| 553 | entry.thread = try std.Thread.spawn(.{}, Context.run, .{ &ctx, index }); |
| 555 | 554 | } |
| 556 | 555 | |
| 557 | 556 | ctx.threads[0].signal.notify(); |