From 168bea7e78955933004d6d9654aa7b742c7ce952 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Sat, 24 Dec 2022 02:47:20 +0100 Subject: [PATCH] src/context.zig: add a waiting_event TODO list. --- zig-impl/src/context.zig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/zig-impl/src/context.zig b/zig-impl/src/context.zig index a56e4e4..9c43b1f 100644 --- a/zig-impl/src/context.zig +++ b/zig-impl/src/context.zig @@ -163,6 +163,27 @@ pub const Context = struct { // TODO: listening to these file descriptors. var some_event = Event.init(Event.Type.CONNECTION, 5, 8, null); return some_event; + + // TODO: set POLLIN & POLLOUT flags in the pollfd structure + // for each fd + // TODO: before initiate a timer + // TODO: poll syscall + // TODO: timer = end - start; if 0 => return timer event + // TODO: handle messages + // => loop over ctx.size + // => if pollfd[i].revents is set to POLLIN + // => if fd is SERVER => new connection + // => if fd is SWITCHED => msg to exchange (or drop the switch) + // => if fd is EXTERNAL => let user handle IO operations + // => otherwise => new message or disconnection + // => if fd revent is POLLOUT + // => if SWITCHED => write message for its switch buddy + // => otherwise => write message for the msg.fd + // if fd revent is POLLHUP + // => handle disconnection: + // close + remove fd from pollfd + return event + // if fd revent is POLLERR or POLLNVAL + // => return error event } pub fn close(self: *Self, index: usize) !void {