Skip to content

Proposal: a way to check async frame liveness #3164

Open
@fengb

Description

@fengb

There are a few instances where it can be ambiguous whether an async function has completed:

  1. Error handling — the example uses errdefer if (!awaited_download_frame) { but this can be converted to be errdefer if (!@frameState(download_frame).awaited) {
  2. Generators — liveness is an indicator of completion, but there's currently not a way for the execution context to check

It'd be nice if we could check the "state" of the async function. Braindump:

const FrameState = struct {
    running: bool, // not sure if we should expose "suspended" as it sounds like a concurrent problem
    awaited: bool,
};

@frameState(f: anyframe) FrameState

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions