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: Boolean Always returns |
|
val isCancelled: Boolean Always returns |
|
val isCompleted: Boolean Always returns |
|
val onJoin: SelectClause0 Clause 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): DisposableHandle Always returns NonDisposableHandle and does not do anything. |
|
Always returns |
|
Does not do anything. |
|
fun getCancellationException(): CancellationException Always throws IllegalStateException. |
|
fun invokeOnCompletion( fun invokeOnCompletion( fun invokeOnCompletion( fun invokeOnCompletion( Always returns NonDisposableHandle. |
|
suspend fun join(): Unit Always throws UnsupportedOperationException. |
|
fun start(): Boolean Always 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. |