Skip to content

support break in suspend blocks #803

@andrewrk

Description

@andrewrk

Internally, await is a suspend block that reaches into the coroutine's frame, atomically modifies the awaiter pointer, and then based on the previous value of the awaiter pointer, might decide not to suspend after all.

We could expose this ability to zig programmers, like this:

suspend |p| {
    const prev_value = @atomicRmw(usize, &something, AtomicRmwOp.Xchg, something_else, AtomicOrder.SeqCst);
    if (prev_value == 0) {
        queue(p);
    } else {
        break;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions