Skuld.FiberPool.Main (skuld v0.27.2)
View SourceMain computation driver for the FiberPool.
Orchestrates fiber execution on behalf of the main computation. Called from two sites — each handling a different class of pending work:
InternalSuspend.ISentinel.run— drainsInternalSuspendsentinels (Await, Batch, Channel) at theComp.runboundary. When the main computation awaits fiber results and suspends, the scheduler steps fibers until the await is satisfied, then resumes the main computation.FiberPool.with_handler— drains fire-and-forget fibers (spawned but not awaited) on normal completion, while scoped effect state is still live.
This module does not schedule individual fibers — that's Scheduler's job.
It sits one level above, calling Scheduler.step/2 in a loop while checking
whether the main computation can proceed.
Dependency Layering
InternalSuspenddepends on this module (via ISentinel.run → drain_pending)Skuld.Effects.FiberPooldepends on this module (via with_handler)- Both depend on
CompandSkuld.Coroutine.* Compdoes not depend on any Fiber module
InternalSuspend sentinels propagate through Comp.bind without firing
continuations, so drain_comp inside FiberPool.with_handler cannot
intercept them. ISentinel at the Comp.run boundary is the natural
dispatch point.
Summary
Functions
Drain any pending fibers and tasks accumulated during computation execution.
Functions
@spec drain_pending(term(), Skuld.Comp.Types.env()) :: {term(), Skuld.Comp.Types.env()}
Drain any pending fibers and tasks accumulated during computation execution.
Called by Comp.run/1 after Comp.call/3. If no fibers or tasks are
pending (and the result is not an await suspension), this is a fast-path
no-op.
Returns {result, env} — either the original values unchanged (fast path)
or the final values after all fibers and tasks have completed.