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/ › Kqueue.zig › deinit
deinit
Kqueue.deinit
pub fn deinit (k : *Kqueue ) void
File
Code
pub fn deinit (k : *Kqueue ) void {
const active_threads = @atomicLoad (u32 , &k .threads .active , .acquire );
for (k .threads .allocated [0 ..active_threads ]) |*thread | {
const ready_fiber = @atomicLoad (?*Fiber , &thread .ready_queue , .monotonic );
assert (ready_fiber == null or ready_fiber == Fiber .finished );
}
k .yield (null , .exit );
const main_thread = &k .threads .allocated [0 ];
const gpa = k .gpa ;
main_thread .deinit (gpa );
const allocated_ptr : [*]align (@alignOf (Thread )) u8 = @ptrCast (@alignCast (k .threads .allocated .ptr ));
const idle_stack_end_offset = std .mem .alignForward (usize , k .threads .allocated .len * @sizeOf (Thread ) + idle_stack_size , std .heap .page_size_max );
for (k .threads .allocated [1 ..active_threads ]) |*thread | thread .thread .join ();
gpa .free (allocated_ptr [0 ..idle_stack_end_offset ]);
k .* = undefined ;
}