coroutineworker / com.autodesk.coroutineworker / CoroutineWorker

CoroutineWorker

expect class CoroutineWorker

Platform and version requirements: JVM

Encapsulates performing background work. On JVM, this use coroutines outright. In native, this uses Worker threads and manages its mutability/concurrency issues.

Constructors

<init>

CoroutineWorker()

Properties

coroutineContext

val coroutineContext: <ERROR CLASS>

Functions

cancel

fun cancel(): Unit

Cancels the underlying Job

cancelAndJoin

suspend fun cancelAndJoin(): Unit

Cancel the underlying job/worker and waits for it to receive its cancellation message or complete

Companion Object Functions

execute

fun execute(block: suspend <ERROR CLASS>.() -> Unit): CoroutineWorker

Enqueues the background work to run and returns a reference to the worker, which can be cancelled

performAndWait

suspend fun <T> performAndWait(block: suspend <ERROR CLASS>.() -> T): T

Enqueues the background work to run, suspends while the work is in progress, and returns the result of that background work back to the calling thread