cancel

abstract fun cancel(reason: String = "Cancelled by user")(source)

Requests cooperative cancellation of the run.

The public lifecycle is cancelled immediately: RunEvent.RunCancelled is emitted and result resolves as RunResult.Cancelled as soon as this handle wins the terminal lifecycle state. The worker coroutine is then cancelled cooperatively; if a replication is already executing, it may finish before worker cleanup observes the cancellation.

Calling cancel more than once, or after the run has already ended, is safe and has no effect.

Parameters

reason

a human-readable explanation, shown in RunEvent.RunCancelled and RunResult.Cancelled; defaults to "Cancelled by user"