mirror of
https://git.robbyzambito.me/zits
synced 2026-02-04 11:44:48 +00:00
Add branch hint for message publish
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user