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 › compiler/ › Maker/ › WebServer.zig › updateTimeReportGeneric
updateTimeReportGeneric
WebServer.updateTimeReportGeneric
pub fn updateTimeReportGeneric (ws : *WebServer , step_index : Configuration .Step .Index , duration : Io .Duration ) void
File
Code
pub fn updateTimeReportGeneric (ws : *WebServer , step_index : Configuration .Step .Index , duration : Io .Duration ) void {
const graph = ws .graph ;
const io = graph .io ;
const configured = &ws .configured .?;
const maker = configured .maker ;
const gpa = maker .gpa ;
const all_steps = maker .step_stack .keys ();
const step_idx : u32 = for (all_steps , 0 ..) |s , i | {
if (s == step_index ) break @intCast (i );
} else unreachable ;
const old_buf = old : {
configured .time_report_mutex .lock (io ) catch return ;
defer configured .time_report_mutex .unlock (io );
const old = configured .time_report_msgs [step_idx ];
configured .time_report_msgs [step_idx ] = &.{};
break :old old ;
};
const buf = gpa .realloc (old_buf , @sizeOf (abi .time_report .GenericResult )) catch @panic ("out of memory" );
const out : *align (1 ) abi .time_report .GenericResult = @ptrCast (buf );
out .* = .{
.step_idx = step_idx ,
.ns_total = @intCast (duration .toNanoseconds ()),
};
{
configured .time_report_mutex .lock (io ) catch return ;
defer configured .time_report_mutex .unlock (io );
assert (configured .time_report_msgs [step_idx ].len == 0 );
configured .time_report_msgs [step_idx ] = buf ;
configured .time_report_update_times [step_idx ] = ws .now ();
}
ws .notifyUpdate ();
}