an experimental irc client

write: increase write loop queue size

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>

+5 -8
+4 -4
src/app.zig
··· 177 177 178 178 // start our write thread 179 179 var write_queue: comlink.WriteQueue = .{}; 180 - const write_thread = try std.Thread.spawn(.{}, writeLoop, .{&write_queue}); 180 + const write_thread = try std.Thread.spawn(.{}, writeLoop, .{ self.alloc, &write_queue }); 181 181 defer { 182 182 write_queue.push(.join); 183 183 write_thread.join(); ··· 1869 1869 1870 1870 /// this loop is run in a separate thread and handles writes to all clients. 1871 1871 /// Message content is deallocated when the write request is completed 1872 - fn writeLoop(queue: *comlink.WriteQueue) !void { 1872 + fn writeLoop(alloc: std.mem.Allocator, queue: *comlink.WriteQueue) !void { 1873 1873 log.debug("starting write thread", .{}); 1874 1874 while (true) { 1875 1875 const req = queue.pop(); 1876 1876 switch (req) { 1877 1877 .write => |w| { 1878 1878 try w.client.write(w.msg); 1879 - w.allocator.free(w.msg); 1879 + alloc.free(w.msg); 1880 1880 }, 1881 1881 .join => { 1882 1882 while (queue.tryPop()) |r| { 1883 1883 switch (r) { 1884 - .write => |w| w.allocator.free(w.msg), 1884 + .write => |w| alloc.free(w.msg), 1885 1885 else => {}, 1886 1886 } 1887 1887 }
+1 -2
src/comlink.zig
··· 8 8 pub const App = app.App; 9 9 pub const Completer = completer.Completer; 10 10 pub const EventLoop = vaxis.Loop(Event); 11 - pub const WriteQueue = vaxis.Queue(WriteEvent, 64); 11 + pub const WriteQueue = vaxis.Queue(WriteEvent, 256); 12 12 13 13 pub const Bind = struct { 14 14 key: vaxis.Key, ··· 93 93 write: struct { 94 94 client: *irc.Client, 95 95 msg: []const u8, 96 - allocator: std.mem.Allocator, 97 96 }, 98 97 join, 99 98 };
-2
src/irc.zig
··· 660 660 self.write_queue.push(.{ .write = .{ 661 661 .client = self, 662 662 .msg = msg, 663 - .allocator = self.alloc, 664 663 } }); 665 664 } 666 665 ··· 670 669 self.write_queue.push(.{ .write = .{ 671 670 .client = self, 672 671 .msg = try self.alloc.dupe(u8, msg), 673 - .allocator = self.alloc, 674 672 } }); 675 673 } 676 674