Add branch hint for message publish

This commit is contained in:
2025-12-09 21:15:27 -05:00
parent 45e8c4cc08
commit 5fd580045d

View File

@@ -40,10 +40,8 @@ pub const ClientState = struct {
self: *ClientState,
io: std.Io,
) void {
std.debug.print("out pointer in write proc: {*}\n", .{self.to_client});
std.debug.print("recv queue in write proc: {*}\n", .{&self.recv_queue});
while (true) {
const message = self.recv_queue.getOne(io) catch continue;
const message = self.recv_queue.getOne(io) catch break;
std.debug.print("got message in write loop to send to client: {any}\n", .{message});
switch (message) {
.@"+ok" => {
@@ -56,7 +54,12 @@ pub const ClientState = struct {
writeInfo(self.to_client, info) catch break;
},
.msg => |m| {
writeMsg(self.to_client, m) catch break;
if (writeMsg(self.to_client, m)) |_| {
@branchHint(.likely);
} else |_| {
@branchHint(.unlikely);
break;
}
},
else => {
std.debug.panic("unimplemented write", .{});
@@ -91,7 +94,7 @@ fn writeOk(out: *std.Io.Writer) !void {
try out.flush();
}
pub fn writePong(out: *std.Io.Writer) !void {
fn writePong(out: *std.Io.Writer) !void {
std.debug.print("out pointer: {*}\n", .{out});
std.debug.print("writing pong\n", .{});
_ = try out.write("PONG\r\n");