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 standard library. Private Function
fnupdateTask(io: Io) WorkerError!void {
// Store this data in the thread so that it does not need to be part of the// linker data of the main executable.varserialized_buffer: Serialized.Buffer = undefined;
serialized_buffer.init();
deferserialized_buffer.batch.cancel(io);
// In this function we bypass the wrapper code inside `Io.lockStderr` /// `Io.tryLockStderr` in order to avoid clearing the terminal twice.// We still want to go through the `Io` instance however in case it uses a// task-switching mutex.trymaybeUpdateSize(io, trywait(io, global_progress.initial_delay_ns));
errdefer {
constcancel_protection = io.swapCancelProtection(.blocked);
defer_ = io.swapCancelProtection(cancel_protection);
conststderr = io.vtable.lockStderr(io.userdata, null) catch |err| switch (err) {
error.Canceled => unreachable, // blocked
};
deferio.unlockStderr();
clearWrittenWithEscapeCodes(stderr.file_writer) catch {};
}
while (true) {
constbuffer, _ = trycomputeRedraw(io, &serialized_buffer);
if (tryio.vtable.tryLockStderr(io.userdata, null)) |locked_stderr| {
deferio.unlockStderr();
global_progress.need_clear = true;
locked_stderr.file_writer.interface.writeAll(buffer) catch |err| switch (err) {
error.WriteFailed => returnlocked_stderr.file_writer.err.?,
};
}
trymaybeUpdateSize(io, trywait(io, global_progress.refresh_rate_ns));
}
}