Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 standard library. Private Function

waitForCancelWithSignaling

Private Function
std.Io.Threaded.Group.waitForCancelWithSignaling
fn waitForCancelWithSignaling(
        g: Group,
        t: *Threaded,
        num_completed: *std.atomic.Value(u32),
        skip_signals: bool,
    ) void

The caller has canceled g. Inform any threads working on that group of the cancelation if necessary, and wait for g to finish (indicated by num_completed being incremented from 0 to 1), while sending regular signals to threads if necessary for them to unblock from any cancelable syscalls.

skip_signals means it is already known that no threads are currently working on the group so no notifications or signals are necessary.

Params

File

Io/Threaded.zig:609
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
    fn waitForCancelWithSignaling(
        g: Group,
        t: *Threaded,
        num_completed: *std.atomic.Value(u32),
        skip_signals: bool,
    ) void {
        var need_signal: bool = !skip_signals and g.cancelThreads(t);
        var timeout_ns: u64 = 1 << 10;
        while (true) {
            need_signal = need_signal and g.signalAllCanceledSyscalls(t);
            Thread.futexWaitUncancelable(&num_completed.raw, 0, if (need_signal) timeout_ns else null);
            switch (num_completed.load(.acquire)) { // acquire task results
                0 => {},
                1 => break,
                else => unreachable,
            }
            timeout_ns <<|= 1;
        }
    }