Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › Io/ › Uring.zig › deinit
deinit
Uring.deinit
pub fn deinit (ev : *Evented ) void
File
Code
pub fn deinit (ev : *Evented ) void {
const main_fiber : *Fiber = @ptrCast (&ev .main_fiber_buffer );
assert (Thread .current ().currentFiber () == main_fiber );
const active_threads = @atomicLoad (u32 , &ev .threads .active , .acquire );
for (ev .threads .allocated [0 ..active_threads ]) |*thread | {
const ready_fiber = @atomicLoad (?*Fiber , &thread .ready_queue , .monotonic );
assert (ready_fiber == null or ready_fiber == Fiber .finished );
}
ev .yield (null , .exit );
ev .null_fd .close ();
ev .random_fd .close ();
const allocated_ptr : [*]align (@alignOf (Thread )) u8 = @ptrCast (@alignCast (ev .threads .allocated .ptr ));
const idle_stack_end_offset = std .mem .alignForward (
usize ,
ev .threads .allocated .len * @sizeOf (Thread ) + idle_stack_size ,
std .heap .pageSize (),
);
for (ev .threads .allocated [1 ..active_threads ]) |*thread | thread .thread .join ();
for (ev .threads .allocated [0 ..active_threads ]) |*thread | thread .deinit (ev .backing_allocator );
assert (active_threads == ev .threads .active );
ev .backing_allocator .free (allocated_ptr [0 ..idle_stack_end_offset ]);
ev .* = undefined ;
}