Open
Description
There are a few instances where it can be ambiguous whether an async function has completed:
- Error handling — the example uses
errdefer if (!awaited_download_frame) {
but this can be converted to beerrdefer if (!@frameState(download_frame).awaited) {
- 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