init
Function parameters
Parameters
- name:[]const u8
- estimated_total_items:usize
Type definitions in this namespace
Types
- Node
- Represents one unit of progress.
Initializes a global Progress instance.
Functions
- start
- Initializes a global Progress instance.
- lockStdErr
- Allows the caller to freely write to stderr until `unlockStdErr` is called.
- lockStderrWriter
- Allows the caller to freely write to the returned `Writer`,
= switch (builtin.os.tag) { .wasi, .freestanding, .windows => false, else => true, }
Values
- have_ipc
- = switch (builtin.os.tag) { .wasi, .freestanding, .windows => false, else => true, }
Source
Implementation
fn init(free_index: Index, parent: Parent, name: []const u8, estimated_total_items: usize) Node {
assert(parent == .none or @intFromEnum(parent) < node_storage_buffer_len);
const storage = storageByIndex(free_index);
@atomicStore(u32, &storage.completed_count, 0, .monotonic);
@atomicStore(u32, &storage.estimated_total_count, std.math.lossyCast(u32, estimated_total_items), .monotonic);
const name_len = @min(max_name_len, name.len);
copyAtomicStore(storage.name[0..name_len], name[0..name_len]);
if (name_len < storage.name.len)
@atomicStore(u8, &storage.name[name_len], 0, .monotonic);
const parent_ptr = parentByIndex(free_index);
if (std.debug.runtime_safety) {
assert(@atomicLoad(Node.Parent, parent_ptr, .monotonic) == .unused);
}
@atomicStore(Node.Parent, parent_ptr, parent, .monotonic);
return .{ .index = free_index.toOptional() };
}