(sigil async core)
Cooperative scheduling and external waits. Host I/O, timers and signals are installed by (sigil async).
Exports
make-schedulerprocedureCreate a new scheduler.
scheduler-spawnprocedureAdd a new task to the scheduler.
scheduler-runprocedureRun 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.
yieldprocedureYield control to the scheduler.
Allows other tasks to run before continuing.
in-async-context?procedureCheck 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"))current-schedulervariable(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)
await-externalvariable(No description)
scheduler-task-countvariable(No description)
scheduler-blocked-countvariable(No description)
async-prompt-tagvariable(No description)
scheduler-enqueue!variable(No description)
scheduler-dec-blocked!variable(No description)
%async-has-io-waiters?variable(No description)
%async-has-fd-waiters?variable(No description)
%async-has-timer-waiters?variable(No description)
%async-has-external-waiters?variable(No description)
%async-scheduler-empty?variable(No description)
%async-process-external-waiters!variable(No description)
%async-install-poll-service!variable(No description)
%async-install-external-service!variable(No description)
%async-install-timer-service!variable(No description)
%async-install-signal-service!variable(No description)
%async-service-signals!variable(No description)