Function end [src]

Finish a started Node. Thread-safe.

Prototype

pub fn end(n: Node) void

Parameters

n: Node

Source

pub fn end(n: Node) void { if (noop_impl) { assert(n.index == .none); return; } const index = n.index.unwrap() orelse return; const parent_ptr = parentByIndex(index); if (parent_ptr.unwrap()) |parent_index| { _ = @atomicRmw(u32, &storageByIndex(parent_index).completed_count, .Add, 1, .monotonic); @atomicStore(Node.Parent, parent_ptr, .unused, .seq_cst); const freelist_head = &global_progress.node_freelist_first; var first = @atomicLoad(Node.OptionalIndex, freelist_head, .seq_cst); while (true) { @atomicStore(Node.OptionalIndex, freelistByIndex(index), first, .seq_cst); first = @cmpxchgWeak(Node.OptionalIndex, freelist_head, first, index.toOptional(), .seq_cst, .seq_cst) orelse break; } } else { @atomicStore(bool, &global_progress.done, true, .seq_cst); global_progress.redraw_event.set(); if (global_progress.update_thread) |thread| thread.join(); } }