Skuld.Fiber.FiberPool.Main (skuld v0.23.0)
View SourceMain computation driver for the FiberPool.
Orchestrates fiber execution on behalf of the main computation — the
computation passed to Comp.run/1. Its responsibilities:
- Drain pending work:
Comp.run/1callsdrain_pending/2afterComp.call/3to schedule any fibers or tasks spawned during execution. - Drive the main computation's await/resume cycle: when the main computation suspends awaiting fiber results, this module steps the Scheduler until the await is satisfied, then resumes the main computation.
- Run fibers to completion: when the main computation has already
finished but background fibers remain, delegates to
Scheduler.run/2to drain them.
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
Compdepends on this module (callsdrain_pending/2)Skuld.Effects.FiberPooldepends onCompandSkuld.Fiber.*- This module depends on
Skuld.Fiber.*(infrastructure only)
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.