ProgressScope

interface ProgressScope : CoroutineScope

The receiver scope of an asyncWithProgress block: a CoroutineScope that can report progress and divide the remaining bar into sequential slices.

report may be called from any thread. slice must be called sequentially from the job's own flow; slices are windows allocated left to right, not a concurrent tree. For parallel work, route completions through report(done, total), whose counter is monotonic.

Properties

Link copied to clipboard

Functions

Link copied to clipboard
fun <T> CoroutineScope.asyncWithProgress(context: CoroutineContext = EmptyCoroutineContext, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend ProgressScope.() -> T): ProgressFuture<T>

Starts a coroutine like async and returns a ProgressFuture that reports its progress.

Link copied to clipboard
fun CoroutineScope.launchCatching(onError: (Throwable) -> Unit, block: suspend CoroutineScope.() -> Unit): Job

Launches a coroutine that reports failures of block to onError instead of the scope.

Link copied to clipboard
fun CoroutineScope.launchDelayed(delay: Duration, block: suspend CoroutineScope.() -> Unit): Job

Launches a coroutine that runs block after delay.

Link copied to clipboard
fun CoroutineScope.launchPeriodic(interval: Duration, initialDelay: Duration = Duration.ZERO, action: suspend () -> Unit): Job

Launches a coroutine that runs action repeatedly with a fixed pause between runs.

Link copied to clipboard
abstract fun report(fraction: Float?, phase: String? = null)

Reports progress within this scope's window.

abstract fun report(done: Long, total: Long, phase: String? = null)

Reports done of total completed units, or indeterminate when total <= 0.

Link copied to clipboard
abstract fun slice(weight: Float, phase: String? = null): ProgressScope

Allocates the next weight of this scope's window to a sub-scope.