Skuld.Fiber.FiberPool.Main (skuld v0.23.0)

View Source

Main 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/1 calls drain_pending/2 after Comp.call/3 to 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/2 to 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

Summary

Functions

Drain any pending fibers and tasks accumulated during computation execution.

Functions

drain_pending(result, env)

@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.