AsyncGate
A one-shot signal that resumes every waiter when opened.
Opening is permanent and repeatable: later calls to await return immediately. Cancelling a waiting coroutine removes only that waiter.
val gate = AsyncGate()
val job = launch { gate.await(); load() }
waitUntil(1.seconds, observe = { gate.waiterCount }) { it == 1 }
gate.open()Content copied to clipboard