June 2018
Intermediate to advanced
316 pages
6h 34m
English
The async function creates a new coroutine and returns an instance of the Deferred type:
public actual fun <T> async( context: CoroutineContext = DefaultDispatcher, start: CoroutineStart = CoroutineStart.DEFAULT, parent: Job? = null, block: suspend CoroutineScope.() -> T): Deferred<T> { val newContext = newCoroutineContext(context, parent) val coroutine = if (start.isLazy) LazyDeferredCoroutine(newContext, block) else DeferredCoroutine<T>(newContext, active = true) coroutine.initParentJob(newContext[Job]) start(block, coroutine, coroutine) return coroutine}
Deferred is an interface that represents a future result of a coroutine execution:
public actual interface Deferred<out T> : Job { public actual val isCompletedExceptionally: ...Read now
Unlock full access