Fields

next_tick_queue: field_call,
os_data: OsData,
final_resume_node: ResumeNode,
pending_event_count: usize,
extra_threads: []Thread,
fs_thread: Thread,

TODO change this to a pool of configurable number of threads and rename it to be not file-system-specific. it will become a thread pool for turning non-CPU-bound blocking things into async things. A fallback for any missing OS-specific API.

fs_queue: field_call,
fs_end_request: Request.Node,
fs_thread_wakeup: std.Thread.ResetEvent,

For resources that have the same lifetime as the Loop. This is only used by Loop for the thread pool and associated resources.

delay_queue: DelayQueue,

State which manages frames that are sleeping on timers

available_eventfd_resume_nodes: field_call,

Pre-allocated eventfds. All permanently active. This is how Loop sends promises to be resumed on other threads.

eventfd_resume_nodes: []T.Node,

Functions

fn accept(self: *Loop, sockfd: os.socket_t, addr: *os.sockaddr, addr_size: *os.socklen_t, flags: u32) os.AcceptError!os.socket_t

—–– I/0 APIs —––

fn beginOneEvent(self: *Loop) void

call finishOneEvent when done

fn bsdAddKev(self: *Loop, resume_node: *ResumeNode.Basic, ident: usize, filter: i16, flags: u16) !void

resume_node must live longer than the anyframe that it holds a reference to.

fn bsdRemoveKev(self: *Loop, ident: usize, filter: i16) void

No documentation provided.

fn bsdWaitKev(self: *Loop, ident: usize, filter: i16, flags: u16) void

No documentation provided.

fn cancelOnNextTick(self: *Loop, node: *NextTickNode) void

No documentation provided.

fn close(self: *Loop, fd: os.fd_t) void

Performs an async os.close using a separate thread.

fn connect(self: *Loop, sockfd: os.socket_t, sock_addr: *const os.sockaddr, len: os.socklen_t) os.ConnectError!void

No documentation provided.

fn deinit(self: *Loop) void

No documentation provided.

fn faccessatZ(self: *Loop, dirfd: os.fd_t, path_z: [*:0]const u8, mode: u32, flags: u32) os.AccessError!void

Performs an async os.faccessatZ using a separate thread. fd must block and …

Performs an async os.faccessatZ using a separate thread. fd must block and not return EAGAIN.

fn finishOneEvent(self: *Loop) void

No documentation provided.

fn init(self: *Loop) !void

TODO copy elision / named return values so that the threads referencing *Loop h…

TODO copy elision / named return values so that the threads referencing *Loop have the correct pointer value. https://github.com/ziglang/zig/issues/2761 and https://github.com/ziglang/zig/issues/2765

fn initMultiThreaded(self: *Loop) !void

After initialization, call run(). This is the same as initThreadPool using `T…

After initialization, call run(). This is the same as initThreadPool using Thread.getCpuCount to determine the thread pool size. TODO copy elision / named return values so that the threads referencing *Loop have the correct pointer value. https://github.com/ziglang/zig/issues/2761 and https://github.com/ziglang/zig/issues/2765

fn initSingleThreaded(self: *Loop) !void

After initialization, call run(). TODO copy elision / named return values so th…

After initialization, call run(). TODO copy elision / named return values so that the threads referencing *Loop have the correct pointer value. https://github.com/ziglang/zig/issues/2761 and https://github.com/ziglang/zig/issues/2765

fn initThreadPool(self: *Loop, thread_count: usize) !void

Thread count is the total thread count. The thread pool size will be max(thread…

Thread count is the total thread count. The thread pool size will be max(thread_count - 1, 0)

fn linuxAddFd(self: *Loop, fd: i32, resume_node: *ResumeNode, flags: u32) !void

resume_node must live longer than the anyframe that it holds a reference to. fl…

resume_node must live longer than the anyframe that it holds a reference to. flags must contain EPOLLET

fn linuxModFd(self: *Loop, fd: i32, op: u32, flags: u32, resume_node: *ResumeNode) !void

No documentation provided.

fn linuxRemoveFd(self: *Loop, fd: i32) void

No documentation provided.

fn linuxWaitFd(self: *Loop, fd: i32, flags: u32) void

No documentation provided.

fn onNextTick(self: *Loop, node: *NextTickNode) void

Bring your own linked list node. This means it can’t fail.

fn openZ(self: *Loop, file_path: [*:0]const u8, flags: u32, mode: os.mode_t) os.OpenError!os.fd_t

Performs an async os.open using a separate thread.

fn openatZ(self: *Loop, fd: os.fd_t, file_path: [*:0]const u8, flags: u32, mode: os.mode_t) os.OpenError!os.fd_t

Performs an async os.opent using a separate thread.

fn pread(self: *Loop, fd: os.fd_t, buf: []u8, offset: u64, simulate_evented: bool) os.PReadError!usize

Performs an async os.pread using a separate thread. fd must block and not r…

Performs an async os.pread using a separate thread. fd must block and not return EAGAIN.

fn preadv(self: *Loop, fd: os.fd_t, iov: []const os.iovec, offset: u64, simulate_evented: bool) os.ReadError!usize

Performs an async os.preadv using a separate thread. fd must block and not …

Performs an async os.preadv using a separate thread. fd must block and not return EAGAIN.

fn pwrite(self: *Loop, fd: os.fd_t, bytes: []const u8, offset: u64, simulate_evented: bool) os.PerformsWriteError!usize

Performs an async os.pwrite using a separate thread. fd must block and not …

Performs an async os.pwrite using a separate thread. fd must block and not return EAGAIN.

fn pwritev(self: *Loop, fd: os.fd_t, iov: []const os.iovec_const, offset: u64, simulate_evented: bool) os.PWriteError!usize

Performs an async os.pwritev using a separate thread. fd must block and not…

Performs an async os.pwritev using a separate thread. fd must block and not return EAGAIN.

fn read(self: *Loop, fd: os.fd_t, buf: []u8, simulate_evented: bool) os.ReadError!usize

Performs an async os.read using a separate thread. fd must block and not re…

Performs an async os.read using a separate thread. fd must block and not return EAGAIN.

fn readv(self: *Loop, fd: os.fd_t, iov: []const os.iovec, simulate_evented: bool) os.ReadError!usize

Performs an async os.readv using a separate thread. fd must block and not r…

Performs an async os.readv using a separate thread. fd must block and not return EAGAIN.

fn recvfrom(self: *Loop, sockfd: os.fd_t, buf: []u8, flags: u32, src_addr: ?*os.sockaddr, addrlen: ?*os.socklen_t) os.RecvFromError!usize

No documentation provided.

fn run(self: *Loop) void

No documentation provided.

fn runDetached(self: *Loop, alloc: mem.Allocator, comptime func: anytype, args: anytype) error{OutOfMemory}!void

Runs the provided function asynchronously. The function’s frame is allocated wi…

Runs the provided function asynchronously. The function’s frame is allocated with allocator and freed when the function returns. func must return void and it can be an async function. Yields to the event loop, running the function on the next tick.

fn sendto(self: *Loop, sockfd: os.fd_t, buf: []const u8, flags: u32, dest_addr: ?*const os.sockaddr, addrlen: os.socklen_t) os.SendToError!usize

No documentation provided.

fn sleep(self: *Loop, nanoseconds: u64) void

No documentation provided.

fn startCpuBoundOperation() void

If the build is multi-threaded and there is an event loop, then it calls yield

If the build is multi-threaded and there is an event loop, then it calls yield. Otherwise, does nothing.

fn waitUntilFdReadable(self: *Loop, fd: os.fd_t) void

No documentation provided.

fn waitUntilFdWritable(self: *Loop, fd: os.fd_t) void

No documentation provided.

fn waitUntilFdWritableOrReadable(self: *Loop, fd: os.fd_t) void

No documentation provided.

fn write(self: *Loop, fd: os.fd_t, bytes: []const u8, simulate_evented: bool) os.WriteError!usize

Performs an async os.write using a separate thread. fd must block and not r…

Performs an async os.write using a separate thread. fd must block and not return EAGAIN.

fn writev(self: *Loop, fd: os.fd_t, iov: []const os.iovec_const, simulate_evented: bool) os.WriteError!usize

Performs an async os.writev using a separate thread. fd must block and not …

Performs an async os.writev using a separate thread. fd must block and not return EAGAIN.

fn yield(self: *Loop) void

Yielding lets the event loop run, starting any unstarted async operations. Note…

Yielding lets the event loop run, starting any unstarted async operations. Note that async operations automatically start when a function yields for any other reason, for example, when async I/O is performed. This function is intended to be used only when CPU bound tasks would be waiting in the event loop but never get started because no async I/O is performed.