NonCancellable
object NonCancellable : AbstractCoroutineContextElement, Job (source)A non-cancelable job that is always active. It is designed for withContext function to prevent cancellation of code blocks that need to be executed without cancellation.
Use it like this:
withContext(NonCancellable) {
// this code will not be cancelled
}
Properties
|
Always returns emptySequence. |
|
val isActive: BooleanAlways returns |
|
val isCancelled: BooleanAlways returns |
|
val isCompleted: BooleanAlways returns |
|
val onJoin: SelectClause0Clause for select expression of join suspending function that selects when the job is complete. This clause never fails, even if the job completes exceptionally. |
Functions
fun attachChild(child: Job): DisposableHandleAlways returns NonDisposableHandle and does not do anything. |
|
|
Always returns |
|
|
Does not do anything. |
|
fun getCancellationException(): CancellationExceptionAlways throws IllegalStateException. |
|
fun invokeOnCompletion(fun invokeOnCompletion(fun invokeOnCompletion(fun invokeOnCompletion(Always returns NonDisposableHandle. |
|
suspend fun join(): UnitAlways throws UnsupportedOperationException. |
|
fun start(): BooleanAlways returns |
Extension Functions
fun CoroutineContext.cancel(Cancels Job of this context with an optional cancellation cause. The result is |
|
|
Cancels the job and suspends invoking coroutine until the cancelled job is complete. |
|
fun Job.cancelFutureOnCompletion(Cancels a specified future when this job is complete. |
|
fun Job.disposeOnCompletion(Disposes a specified handle when this job is complete. |
|
|
Suspends coroutine until all children of this job are complete using Job.join for all of them. Unlike Job.join on this job as a whole, it does not wait until this job is complete. |