public class DeferredKt
| Modifier and Type | Method and Description |
|---|---|
static <T> Deferred<T> |
async(CoroutineScope $receiver,
kotlin.coroutines.experimental.CoroutineContext context,
CoroutineStart start,
kotlin.jvm.functions.Function1<? super java.lang.Throwable,kotlin.Unit> onCompletion,
kotlin.jvm.functions.Function2<? super kotlinx.coroutines.experimental.CoroutineScope,? super kotlin.coroutines.experimental.Continuation<? super T>,? extends java.lang.Object> block)
Creates new coroutine and returns its future result as an implementation of
interface Deferred.
The running coroutine is cancelled when the resulting deferred is Job.cancel. |
public static <T> Deferred<T> async(CoroutineScope $receiver, kotlin.coroutines.experimental.CoroutineContext context, CoroutineStart start, kotlin.jvm.functions.Function1<? super java.lang.Throwable,kotlin.Unit> onCompletion, kotlin.jvm.functions.Function2<? super kotlinx.coroutines.experimental.CoroutineScope,? super kotlin.coroutines.experimental.Continuation<? super T>,? extends java.lang.Object> block)
Creates new coroutine and returns its future result as an implementation of interface Deferred.
The running coroutine is cancelled when the resulting deferred is Job.cancel.
Coroutine context is inherited from a interface CoroutineScope, additional context elements can be specified with context argument.
If the context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used.
The parent job is inherited from a interface CoroutineScope as well, but it can also be overridden
with corresponding coroutineContext element.
By default, the coroutine is immediately scheduled for execution.
Other options can be specified via start parameter. See enum CoroutineStart for details.
An optional start parameter can be set to CoroutineStart.LAZY to start coroutine lazily. In this case,,
the resulting interface Deferred is created in new state. It can be explicitly started with Job.start
function and will be started implicitly on the first invocation of Job.join, Deferred.await or AwaitKt.awaitAll.
context - additional to CoroutineScope.getCoroutineContext context of the coroutine.start - coroutine start option. The default value is CoroutineStart.DEFAULT.onCompletion - optional completion handler for the coroutine (see Job.invokeOnCompletion).block - the coroutine code.interface Deferred,
Job.cancel,
interface CoroutineScope,
ContinuationInterceptor,
interface CoroutineScope,
coroutineContext,
enum CoroutineStart,
interface Deferred,
Job.start,
Job.join,
Deferred.await,
AwaitKt.awaitAll