Function start [src]

Create a new child progress node. Thread-safe. Passing 0 for estimated_total_items means unknown.

Prototype

pub fn start(node: Node, name: []const u8, estimated_total_items: usize) Node

Parameters

node: Nodename: []const u8estimated_total_items: usize

Source

pub fn start(node: Node, name: []const u8, estimated_total_items: usize) Node { if (noop_impl) { assert(node.index == .none); return Node.none; } const node_index = node.index.unwrap() orelse return Node.none; const parent = node_index.toParent(); const freelist_head = &global_progress.node_freelist_first; var opt_free_index = @atomicLoad(Node.OptionalIndex, freelist_head, .seq_cst); while (opt_free_index.unwrap()) |free_index| { const freelist_ptr = freelistByIndex(free_index); const next = @atomicLoad(Node.OptionalIndex, freelist_ptr, .seq_cst); opt_free_index = @cmpxchgWeak(Node.OptionalIndex, freelist_head, opt_free_index, next, .seq_cst, .seq_cst) orelse { // We won the allocation race. return init(free_index, parent, name, estimated_total_items); }; } const free_index = @atomicRmw(u32, &global_progress.node_end_index, .Add, 1, .monotonic); if (free_index >= global_progress.node_storage.len) { // Ran out of node storage memory. Progress for this node will not be tracked. _ = @atomicRmw(u32, &global_progress.node_end_index, .Sub, 1, .monotonic); return Node.none; } return init(@enumFromInt(free_index), parent, name, estimated_total_items); }