Skip to content

Commit

Permalink
Clarify withContext(NonCancellable) behavior (#2400)
Browse files Browse the repository at this point in the history
Fixes #2383
  • Loading branch information
elizarov authored Nov 18, 2020
1 parent 31a8df0 commit 81577b2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kotlinx-coroutines-core/common/src/Builders.common.kt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ private class LazyDeferredCoroutine<T>(
* which means that if the original [coroutineContext], in which `withContext` was invoked,
* is cancelled by the time its dispatcher starts to execute the code,
* it discards the result of `withContext` and throws [CancellationException].
*
* The cancellation behaviour described above is enabled if and only if the dispatcher is being changed.
* For example, when using `withContext(NonCancellable) { ... }` there is no change in dispatcher and
* this call will not be cancelled neither on entry to the block inside `withContext` nor on exit from it.
*/
public suspend fun <T> withContext(
context: CoroutineContext,
Expand Down

0 comments on commit 81577b2

Please sign in to comment.