mirror of
https://git.robbyzambito.me/zits
synced 2026-02-04 03:34:48 +00:00
Add branch hint for message publish
This commit is contained in:
@@ -40,10 +40,8 @@ pub const ClientState = struct {
|
|||||||
self: *ClientState,
|
self: *ClientState,
|
||||||
io: std.Io,
|
io: std.Io,
|
||||||
) void {
|
) 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) {
|
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});
|
std.debug.print("got message in write loop to send to client: {any}\n", .{message});
|
||||||
switch (message) {
|
switch (message) {
|
||||||
.@"+ok" => {
|
.@"+ok" => {
|
||||||
@@ -56,7 +54,12 @@ pub const ClientState = struct {
|
|||||||
writeInfo(self.to_client, info) catch break;
|
writeInfo(self.to_client, info) catch break;
|
||||||
},
|
},
|
||||||
.msg => |m| {
|
.msg => |m| {
|
||||||
writeMsg(self.to_client, m) catch break;
|
if (writeMsg(self.to_client, m)) |_| {
|
||||||
|
@branchHint(.likely);
|
||||||
|
} else |_| {
|
||||||
|
@branchHint(.unlikely);
|
||||||
|
break;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
else => {
|
else => {
|
||||||
std.debug.panic("unimplemented write", .{});
|
std.debug.panic("unimplemented write", .{});
|
||||||
@@ -91,7 +94,7 @@ fn writeOk(out: *std.Io.Writer) !void {
|
|||||||
try out.flush();
|
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("out pointer: {*}\n", .{out});
|
||||||
std.debug.print("writing pong\n", .{});
|
std.debug.print("writing pong\n", .{});
|
||||||
_ = try out.write("PONG\r\n");
|
_ = try out.write("PONG\r\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user