(sigil async core)

Cooperative scheduling and external waits. Host I/O, timers and signals are installed by (sigil async).

Exports

Create a new scheduler.

Add a new task to the scheduler.

scheduler-runprocedure

Run all scheduler tasks until completion or deadlock.

*current-scheduler* is restored on EVERY exit — the normal return branches AND the exception path when a task raises uncaught and the error unwinds through scheduler-run. Restoring only on the normal branches (the historical bug) leaked the scheduler during unwinding, which is the precondition that let an async-port write (e.g. a logger in a dynamic-wind cleanup, or an outer exception handler) attempt to abort-to-prompt with no live prompt — the async-port logging-recursion class.

We use a guard (catch → restore → re-raise), NOT dynamic-wind: a dynamic-wind after-thunk is silently SKIPPED when an exception unwinds through the call-with-prompt that run-task installs around each task body (a VM unwind quirk — guard, being an exception handler, still fires across the prompt). Task yields use abort-to-prompt to that per-task prompt installed BELOW this frame, so they never reach this guard; only a genuinely uncaught task exception does.

yieldprocedure

Yield control to the scheduler.

Allows other tasks to run before continuing.

Check if currently running in an async context.

Returns #t if running inside with-async, #f otherwise. Useful for writing code that behaves differently in sync vs async contexts.

(if (in-async-context?)
    (display "running async\n")
    (display "running sync\n"))

(No description)

scheduler?variable

(No description)

with-asyncvariable

(No description)

%run-asyncvariable

(No description)

resume-asyncvariable

(No description)

govariable

(No description)

%go-spawnvariable

(No description)

when-asyncvariable

(No description)

if-asyncvariable

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)

(No description)