| author | |
| committer | |
| log | 9292ded5a3b8c82ae731bb18d40c69b7e40177f8 |
| tree | 154bceeaf82e3e96caab244932939dbc7e34a4d3 |
| parent | e73257dec2d997e9d573419178695992790a9525 |
closes #31730
closes #317572 files changed, 7 insertions(+), 6 deletions(-)
lib/std/Io.zig+2-2| ... | ... | @@ -500,8 +500,8 @@ pub const Batch = struct { |
| 500 | 500 | /// Returns the index that will be returned by `next` after the operation completes. |
| 501 | 501 | /// Asserts that no more than `storage.len` operations are active at a time. |
| 502 | 502 | pub fn add(batch: *Batch, operation: Operation) u32 { |
| 503 | const index = batch.unused.next; | |
| 504 | batch.addAt(index.toIndex(), operation); | |
| 503 | const index = batch.unused.head.toIndex(); | |
| 504 | batch.addAt(index, operation); | |
| 505 | 505 | return index; |
| 506 | 506 | } |
| 507 | 507 |
lib/std/Io/test.zig+5-4| ... | ... | @@ -692,14 +692,15 @@ test "read from a file using Batch.awaitAsync API" { |
| 692 | 692 | var storage: [2]Io.Operation.Storage = undefined; |
| 693 | 693 | var batch: Io.Batch = .init(&storage); |
| 694 | 694 | |
| 695 | batch.addAt(0, .{ .file_read_streaming = .{ | |
| 695 | // Tests add API because this provides coverage for both add and addAt. | |
| 696 | try testing.expectEqual(0, batch.add(.{ .file_read_streaming = .{ | |
| 696 | 697 | .file = eyes_file, |
| 697 | 698 | .data = &.{&eyes_buf}, |
| 698 | } }); | |
| 699 | batch.addAt(1, .{ .file_read_streaming = .{ | |
| 699 | } })); | |
| 700 | try testing.expectEqual(1, batch.add(.{ .file_read_streaming = .{ | |
| 700 | 701 | .file = saviour_file, |
| 701 | 702 | .data = &.{&saviour_buf}, |
| 702 | } }); | |
| 703 | } })); | |
| 703 | 704 | |
| 704 | 705 | // This API is supposed to *always* work even if the target has no |
| 705 | 706 | // concurrency primitives available. |