public class CancellableContinuationKt
| Modifier and Type | Method and Description |
|---|---|
static <T> java.lang.Object |
suspendAtomicCancellableCoroutine(boolean holdCancellability,
kotlin.jvm.functions.Function1<? super kotlinx.coroutines.experimental.CancellableContinuation<? super T>,kotlin.Unit> block,
kotlin.coroutines.experimental.Continuation<? super T> $continuation)
Suspends coroutine similar to suspendCancellableCoroutine, but with atomic cancellation.
|
static <T> java.lang.Object |
suspendCancellableCoroutine(boolean holdCancellability,
kotlin.jvm.functions.Function1<? super kotlinx.coroutines.experimental.CancellableContinuation<? super T>,kotlin.Unit> block,
kotlin.coroutines.experimental.Continuation<? super T> $continuation)
Suspends coroutine similar to suspendCoroutine, but provide an implementation of
interface CancellableContinuation to
the block. This function throws CancellationException if the coroutine is cancelled or completed while suspended. |
public static <T> java.lang.Object suspendCancellableCoroutine(boolean holdCancellability,
kotlin.jvm.functions.Function1<? super kotlinx.coroutines.experimental.CancellableContinuation<? super T>,kotlin.Unit> block,
kotlin.coroutines.experimental.Continuation<? super T> $continuation)
Suspends coroutine similar to suspendCoroutine, but provide an implementation of interface CancellableContinuation to
the block. This function throws CancellationException if the coroutine is cancelled or completed while suspended.
If holdCancellability optional parameter is true, then the coroutine is suspended, but it is not
cancellable until CancellableContinuation.initCancellability is invoked.
See suspendAtomicCancellableCoroutine for suspending functions that need atomic cancellation.
public static <T> java.lang.Object suspendAtomicCancellableCoroutine(boolean holdCancellability,
kotlin.jvm.functions.Function1<? super kotlinx.coroutines.experimental.CancellableContinuation<? super T>,kotlin.Unit> block,
kotlin.coroutines.experimental.Continuation<? super T> $continuation)
Suspends coroutine similar to suspendCancellableCoroutine, but with atomic cancellation.
When suspended function throws CancellationException it means that the continuation was not resumed. As a side-effect of atomic cancellation, a thread-bound coroutine (to some UI thread, for example) may continue to execute even after it was cancelled from the same thread in the case when the continuation was already resumed and was posted for execution to the thread's queue.