occupy

fun <T : Seam> occupy(build: () -> T): T

Claims the slot, builds the session, and installs it — as one atomic operation.

Succeeds when the slot is empty or its occupant has latched SeamState.Torn; otherwise throws IllegalStateException with occupiedMessage (a live session already holds the slot). If build throws, the slot is left exactly as it was — a failed session open never wedges the slot — and the exception propagates unchanged (cancellation is preserved: nothing is caught).

Return

the freshly installed seam.

Parameters

build

constructs the Seam to install. Runs under the guard lock, so it must be synchronous (no suspension) and must not re-enter this slot.