feature. See also
. The project being documented here (as the example) is the Zig library itself.
WebServer.updateTimeReportCompile
pub fn updateTimeReportCompile(ws: *WebServer, opts: struct
File
Code
pub fn updateTimeReportCompile(ws: *WebServer, opts: struct {
compile_step: Configuration.Step.Index,
use_llvm: bool,
stats: abi.time_report.CompileResult.Stats,
ns_total: u64,
llvm_pass_timings_len: u32,
files_len: u32,
decls_len: u32,
trailing: []const u8,
}) 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 == opts.compile_step) 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.CompileResult) + opts.trailing.len) catch @panic("out of memory");
const out_header: *align(1) abi.time_report.CompileResult = @ptrCast(buf[0..@sizeOf(abi.time_report.CompileResult)]);
out_header.* = .{
.step_idx = step_idx,
.flags = .{
.use_llvm = opts.use_llvm,
},
.stats = opts.stats,
.ns_total = opts.ns_total,
.llvm_pass_timings_len = opts.llvm_pass_timings_len,
.files_len = opts.files_len,
.decls_len = opts.decls_len,
};
@memcpy(buf[@sizeOf(abi.time_report.CompileResult)..], opts.trailing);
{
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();
}