ScratchPool

class ScratchPool<T : Any>(factory: () -> T)

Sequential scratch pool: hand out T instances in order during a single assembly pass, then reset the cursor at the start of the next pass to reuse the same instances. Distinct from BasicPool which is acquire/release-style — here callers don't release individually because they keep the acquired instances alive in a result list until the entire pass completes.

Grows lazily to the high-water mark across passes; never shrinks. Single-threaded only.

Constructors

Link copied to clipboard
constructor(factory: () -> T)

Functions

Link copied to clipboard
fun acquire(): T

Returns a pooled instance. The caller is expected to overwrite its contents before use.

Link copied to clipboard
fun reset()

Resets the internal cursor so the next acquire reuses instances from the start.