Reference

std/iteration/staged

std/iteration/src/staged.trb

The synchronous driver of a Stage: what Iterate.through(stage) answers.

A stage pushes, an Iterate is pulled, so the driver has two halves and they are not the same code:

type Queueing

type Queueing<Item> with Accumulator<Item, Void>

The tail of a pipeline that somebody pulls from: every value the stage pushes lands in a list the driver also holds. The list is in a Shared box because an accumulator is a value - handing it over would hand over a copy, and the driver would never see what arrived.

field box

var box: Shared<List<Item>>

Shared with the driver that reads it back out, one next() at a time.

fn add

var fn add(value: Item)

Appends the value to the queue the driver reads from.

fn finish

fn finish()

Nothing to do: the values are already in the box.