public class DeferredKt
| Modifier and Type | Method and Description |
|---|---|
static <T> Deferred<T> |
async(kotlin.coroutines.experimental.CoroutineContext context,
CoroutineStart start,
Job parent,
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. |
public static <T> Deferred<T> async(kotlin.coroutines.experimental.CoroutineContext context, CoroutineStart start, Job parent, 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 object is Job.cancel.
The context for the new coroutine can be explicitly specified.
See class CoroutineDispatcher for the standard context implementations that are provided by kotlinx.coroutines.
The CoroutineScope.getCoroutineContext of the parent coroutine from its interface CoroutineScope may be used,
in which case the interface Job of the resulting coroutine is a child of the job of the parent coroutine.
The parent job may be also explicitly specified using parent parameter.
If the context does not have any dispatcher nor any other ContinuationInterceptor, then DefaultDispatcher is used.
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 or Deferred.await.
context - context of the coroutine. The default value is DefaultDispatcher.start - coroutine start option. The default value is CoroutineStart.DEFAULT.parent - explicitly specifies the parent job, overrides job from the context (if any).*block - the coroutine code.interface Deferred,
Job.cancel,
class CoroutineDispatcher,
CoroutineScope.getCoroutineContext,
interface CoroutineScope,
interface Job,
ContinuationInterceptor,
enum CoroutineStart,
interface Deferred,
Job.start,
Job.join,
Deferred.await