closeAndAwait

Closes this tracker like Tracker.close, but suspends instead of blocking, waits until the shutdown has finished and returns its final result. That is the same exposure as Tracker.close, which also returns only when the shutdown is done: the drain is bounded by AutographConfig.closeDrainTimeoutMillis, but the Transport.flush after it is not, so a transport whose flush blocks holds this call for as long as it blocks (#305). The reason it has no timer of its own is not that the shutdown is bounded: a timer equal to the drain bound would race the shutdown (a drain ending just under the bound, plus a flush, would report a completed shutdown as timed out), and the result would not be deterministic. Use closeAndAwait with a timeout when you need to stop waiting.

Returns a result with CloseResult.isUnsupported without closing anything when this tracker has no AwaitableCloseTracker capability — a scoped view does not own the root tracker and must not be able to shut it down. Close the tracker you created, not a view of it. See AwaitableCloseTracker.closeAndAwait for how concurrent and repeated calls behave and what the timeout bounds.

Encoding CloseResult.isUnsupported as !cutoffReached is intentional and frozen.


suspend fun Tracker.closeAndAwait(timeoutMillis: Long): CloseResult

closeAndAwait with an explicit per-call timeoutMillis for the wait. It bounds this caller's wait only, and a value at or above the drain bound does not guarantee the final result; see AwaitableCloseTracker.closeAndAwait. Long.MAX_VALUE waits for the shutdown to finish, as the no-argument overload does.