rebuild

suspend fun <T : Any> rebuild(ref: AggregateRef, replay: suspend () -> T): T?

Runs replay, a reader's rebuild of ref's state, under the gate, and returns what it gives, unless another reader's rebuild of ref runs already: then it waits for that one to end, however it ends, and returns null, so the caller looks again for the view that rebuild left, and rebuilds itself only without one. A rebuild that fails, is cancelled or is refused by the gate ends like one that succeeds: one of the readers that waited for it rebuilds next, and the others wait for that one; none fails with it.

A wait is cancellable: a reader's own timeout, or the end of its lane, ends it, not the rebuild it waits for.