RadioSessionAuthority

Owns admission and revocation for work bound to one transport session.

Inheritors

Properties

Link copied to clipboard
abstract val activeSession: StateFlow<RadioSessionContext?>

The transport session that still owns lifecycle completion, or null after teardown drains every admitted operation. Implementations close admission before teardown, so isSessionActive and the run helpers reject new work immediately even while this flow temporarily retains the draining session.

Functions

Link copied to clipboard

Returns whether session still owns transport admission. Implementations must make this reflect the admission gate, not only activeSession, because the draining session may remain published after new work is rejected.

Link copied to clipboard
abstract fun runIfSessionActive(session: RadioSessionContext, block: () -> Unit): Boolean

Runs block only while session owns transport admission. Implementations must make the admission check and synchronous side effect atomic with teardown.

Link copied to clipboard
open suspend fun runWhileSessionActive(session: RadioSessionContext, block: suspend () -> Unit): Boolean

Runs block while holding the same lifecycle lease, without exposing the lease token. Implementations may serialize this convenience path to preserve handshake ordering; independently deferred work should use runWithSessionLease so it can acquire its own lease before its parent operation returns.

Link copied to clipboard
abstract suspend fun runWithSessionLease(session: RadioSessionContext, block: suspend (RadioSessionLease) -> Unit): Boolean

Acquires a lifecycle lease for suspend block. Once admitted, teardown closes admission to later work and waits for this block to finish before publishing session completion or starting a replacement transport. block may use RadioSessionLease.isCurrent for transaction-bound checks that must remain valid through commit even after teardown has closed new admission. Implementations must acquire and release the lease through the same admission state used by teardown; comparing only activeSession cannot satisfy the draining contract. Callers must keep the block bounded and must not invoke transport lifecycle methods from inside it.