| ... | ... | @@ -2868,10 +2868,14 @@ fn batchAwaitConcurrent(userdata: ?*anyopaque, b: *Io.Batch, timeout: Io.Timeout |
| 2868 | 2868 | } |
| 2869 | 2869 | } = .{ .gpa = t.allocator, .batch = b, .slice = &poll_buffer, .len = 0 }; |
| 2870 | 2870 | { |
| 2871 | var prev_index: Io.Operation.OptionalIndex = .none; |
| 2871 | 2872 | var index = b.submitted.head; |
| 2872 | 2873 | while (index != .none) { |
| 2873 | 2874 | const storage = &b.storage[index.toIndex()]; |
| 2874 | 2875 | const submission = storage.submission; |
| 2876 | const next_index = submission.node.next; |
| 2877 | defer index = next_index; |
| 2878 | |
| 2875 | 2879 | switch (submission.operation) { |
| 2876 | 2880 | .file_read_streaming => |o| try poll_storage.add(o.file.handle, posix.POLL.IN | posix.POLL.ERR), |
| 2877 | 2881 | .file_write_streaming => |o| try poll_storage.add(o.file.handle, posix.POLL.OUT | posix.POLL.ERR), |
| ... | ... | @@ -2891,12 +2895,18 @@ fn batchAwaitConcurrent(userdata: ?*anyopaque, b: *Io.Batch, timeout: Io.Timeout |
| 2891 | 2895 | }; |
| 2892 | 2896 | data_i += msg.data.len; |
| 2893 | 2897 | } else .{ null, o.message_buffer.len } }; |
| 2898 | switch (prev_index) { |
| 2899 | .none => b.submitted.head = next_index, |
| 2900 | else => b.storage[prev_index.toIndex()].submission.node.next = next_index, |
| 2901 | } |
| 2902 | if (next_index == .none) b.submitted.tail = prev_index; |
| 2894 | 2903 | switch (b.completed.tail) { |
| 2895 | 2904 | .none => b.completed.head = index, |
| 2896 | 2905 | else => |tail_index| b.storage[tail_index.toIndex()].completion.node.next = index, |
| 2897 | 2906 | } |
| 2898 | | storage.* = .{ .completion = .{ .node = .{ .next = .none }, .result = result } }; |
| 2899 | 2907 | b.completed.tail = index; |
| 2908 | storage.* = .{ .completion = .{ .node = .{ .next = .none }, .result = result } }; |
| 2909 | continue; |
| 2900 | 2910 | }, |
| 2901 | 2911 | .net_send => |*o| nb: { |
| 2902 | 2912 | const result: Io.Operation.Result = .{ |
| ... | ... | @@ -2920,18 +2930,24 @@ fn batchAwaitConcurrent(userdata: ?*anyopaque, b: *Io.Batch, timeout: Io.Timeout |
| 2920 | 2930 | break :o .{ null, sent }; |
| 2921 | 2931 | }, |
| 2922 | 2932 | }; |
| 2933 | switch (prev_index) { |
| 2934 | .none => b.submitted.head = next_index, |
| 2935 | else => b.storage[prev_index.toIndex()].submission.node.next = next_index, |
| 2936 | } |
| 2937 | if (next_index == .none) b.submitted.tail = prev_index; |
| 2923 | 2938 | switch (b.completed.tail) { |
| 2924 | 2939 | .none => b.completed.head = index, |
| 2925 | 2940 | else => |tail_index| b.storage[tail_index.toIndex()].completion.node.next = index, |
| 2926 | 2941 | } |
| 2927 | | storage.* = .{ .completion = .{ .node = .{ .next = .none }, .result = result } }; |
| 2928 | 2942 | b.completed.tail = index; |
| 2943 | storage.* = .{ .completion = .{ .node = .{ .next = .none }, .result = result } }; |
| 2944 | continue; |
| 2929 | 2945 | }, |
| 2930 | 2946 | .net_accept => |o| try poll_storage.add(o.socket_handle, posix.POLL.IN | posix.POLL.ERR), |
| 2931 | 2947 | .net_read => |o| try poll_storage.add(o.socket_handle, posix.POLL.IN | posix.POLL.ERR), |
| 2932 | 2948 | .net_write => |o| try poll_storage.add(o.socket_handle, posix.POLL.OUT | posix.POLL.ERR), |
| 2933 | 2949 | } |
| 2934 | | index = submission.node.next; |
| 2950 | prev_index = index; |
| 2935 | 2951 | } |
| 2936 | 2952 | } |
| 2937 | 2953 | switch (poll_storage.len) { |