close

override fun close()

Cancels all background coroutines owned by this instance. Idempotent and thread-safe — safe to call multiple times, from any thread, concurrently.

Exactly one caller wins the latch and calls onClose before cancelling ownJob, giving subclasses a chance to perform synchronous cleanup (e.g. clearing retry maps, releasing resources). Every other caller returns immediately, without waiting for the winner — see the class KDoc on why this is a once barrier rather than a completion barrier.

The parentScope passed at construction is not cancelled — only ownJob and its children are stopped.