Skip to documentation
SLOP

tiny.mprompt.yieldPrompt

Reference tiny.mprompt yieldPrompt

Defined in tiny.mprompt.

Suspends the calling code together with p and each nested active prompt, so code running under a prompt suspends back to the point that entered the prompt and hands a resumption to a function there, as a worker does while it waits for its request.

Called byCallsprivate sourcelib.mprompt.src.promptaddOneAfterYieldprivate sourcelib.mprompt.src.promptaddTenAfterYieldprivate sourcelib.mprompt.src.promptasyncWorkerprivate sourcelib.mprompt.src.promptgeneratorprivate sourcelib.mprompt.src.promptcheckedLongjmpprivate sourcelib.mprompt.src.promptguardprivate sourcelib.mprompt.src.promptpromptIsActiveprivate sourcelib.mprompt.src.promptpromptIsAncestorprivate sourcelib.mprompt.src.promptpromptUnlinktiny.syscontextmp setjmptiny.mpromptyieldPrompt
Static calls · unresolved targets: 0 · external targets: 0.

Source

Source: lib/mprompt/src/prompt.zig:553

zig
/// Suspends the calling code together with `p` and each nested active prompt, so code running under/// a prompt suspends back to the point that entered the prompt and hands a resumption to a function/// there, as a worker does while it waits for its request. The call jumps to where `p` was entered/// or last resumed and calls `fun(resumption, arg)` there. The return value of `fun` becomes the/// result of the call that entered or last resumed `p`. The call returns the value passed when the/// resumption is resumed. The call saves the registers at its own point, where a resume jumps, and/// the frames on the suspended stacklets stay as they were. `p` must be an active prompt of the/// calling thread, and assertions check this in safe builds. Before each jump the runtime checks/// the saved stack pointer and jump target against the guard cookie, and a mismatch stops the/// program with a "potential stack corruption detected" panic.pub noinline fn yieldPrompt(p: *Prompt, fun: YieldFn, arg: ?*anyopaque) ?*anyopaque {    assert(promptIsAncestor(p));    assert(promptIsActive(p));    var res: ResumePoint = undefined;    if (context.mp_setjmp(&res.jmp) != 0) {        assert(promptIsActive(p));        assert(promptIsAncestor(p));        return res.result;    }    if (resume_label == null) resume_label = guard(res.jmp.reg_ip);    var sp: ?*anyopaque = null;    const ret = promptUnlink(p, &res, &sp);    ret.fun = fun;    ret.arg = arg;    ret.kind = .yielded;    checkedLongjmp(return_label, sp, &ret.jmp);}

Source: lib/mprompt/src/root.zig:85

zig
pub const yieldPrompt = raw.yieldPrompt;

Audit

Definitions1
Public names1
Members0
Version26.7.0
Revisiondaab053ee433