termio: allow write req pool to grow if needed

This may be necessary if large amounts of data is being written (i.e. a
large clipboard paste). The pool is never shrunk again for now but once
the writes go through the buffer items will of course be reused so its
unlikely to need to continue growing.
This commit is contained in:
Mitchell Hashimoto
2023-03-19 10:25:58 -07:00
parent f03d765020
commit 638e05454f

View File

@ -233,8 +233,8 @@ pub inline fn queueWrite(self: *Exec, data: []const u8) !void {
// our cached buffers that we can queue to the stream. // our cached buffers that we can queue to the stream.
var i: usize = 0; var i: usize = 0;
while (i < data.len) { while (i < data.len) {
const req = try ev.write_req_pool.get(); const req = try ev.write_req_pool.getGrow(self.alloc);
const buf = try ev.write_buf_pool.get(); const buf = try ev.write_buf_pool.getGrow(self.alloc);
const end = @min(data.len, i + buf.len); const end = @min(data.len, i + buf.len);
fastmem.copy(u8, buf, data[i..end]); fastmem.copy(u8, buf, data[i..end]);
ev.data_stream.queueWrite( ev.data_stream.queueWrite(