Skip to content

Execution

2 source file(s), 9 public symbol(s), 9 of them carrying KDoc. Everything below is the documentation that lives beside the code — the same text the completion documentation panel shows in the editor. A blank summary means the declaration has no KDoc yet, not that this page dropped it.

AsyncOperation.kt

A future-backed operation whose callbacks stop firing once the box run that started it ends.

AsyncOperation wraps a java.util.concurrent.CompletableFuture so that progress, result and error callbacks run in the starting box's context and are suppressed after that run is stopped, re-run or retired. Closing it cancels the source future and runs any registered cancellation hooks.

src/jvmMain/kotlin/afield/runtime/lifecycle/AsyncOperation.kt — read the source

Top-level functions

Declaration Summary
fun <T> runAsync(onResult: (T) -> Unit = {}, onError: ((Throwable) -> Unit)? = null, start: AsyncOperation<T>.() -> CompletableFuture<T>): AsyncOperation<T> Start background work with run-owned publication and cleanup. Capture progress before starting:

AsyncOperation

class AsyncOperation<T> internal constructor(private val scope: RunScope?, private val onResult: (T) -> Unit, private val onError: (Throwable) -> Unit) : AutoCloseable

One asynchronous operation owned by the run that started it. progress and the result/error callbacks run only while that run is alive, in its box context, on the completing thread. Keep these callbacks short and non-blocking. Shared clients and cached results are not owned here.

Declaration Summary
val future The result, cancelled when its run ends. Cancelling it also releases this operation.
fun <P> progress(callback: (P) -> Unit): (P) -> Unit Guard a progress callback with this operation's lifetime and originating box context.
fun <R : AutoCloseable> own(resource: R): R Release an operation-local resource on completion, failure or cancellation; never own a shared client.
fun onCancel(cancel: () -> Unit) Request actual worker cancellation on abandonment, separately from cancelling its future.
fun fail(failure: Throwable) Fail this operation, including failures from separately arriving progress transports.
override fun close() Abandon this operation without closing shared clients or removing cached service results.

Timing.kt

src/jvmMain/kotlin/afield/runtime/lifecycle/Timing.kt — read the source

Top-level functions

Declaration Summary
fun bestTimeMs(repetitions: Int = 5, warmup: Int = 2, block: () -> Unit): Double Run warmup untimed calls and return the shortest of repetitions measured calls, in milliseconds. This is a quick local comparison, sensitive to JVM warmup and system load. The block runs repeatedly; exceptions propagate immediately and side effects are not undone.