10 / DATA
once
A body that runs at most once, for the initialisation that must not happen twice, and a pool that builds its objects on the first take and hands them back.
WHERE IT SITS
INTERFACE
struct OncestructA body that runs at most once: the first caller runs it, every later one is a no-op. Guards one-time initialisation, which in a service is a pool, a table or a connection that must not be built twice.
fn Once::new() -> OncefnA body that has not run yet.
fn Once::done(self : Once) -> BoolfnWhether the body has run.
fn Once::run(self : Once, body : () -> Unit) -> BoolfnRun body unless it has already run, and report whether this call ran it.
struct Pool[T]structA pool of reusable objects: a caller takes one, uses it, and hands it back. Building is deferred until the first take, so a pool nobody touches costs nothing — which is what makes it usable for a buffer or a connection that only some code paths need.
fn[T] Pool::new(make : () -> T) -> Pool[T]itemA pool that builds its objects with make.
fn[T] Pool::get(self : Pool[T]) -> TitemTake an object: an idle one when there is one, a fresh one otherwise.
fn[T] Pool::put(self : Pool[T], item : T) -> UnititemHand an object back. The pool keeps every one it is given, so a caller that wants a ceiling on retained objects puts one on its own side.
fn[T] Pool::idle(self : Pool[T]) -> Int32itemHow many objects are idle.