Skip to content

Commit 954503e

Browse files
elizarovpablobaxter
authored andcommitted
Better NonCancellable docs (Kotlin#2633)
1 parent bbb5415 commit 954503e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: kotlinx-coroutines-core/common/src/NonCancellable.kt

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ import kotlin.coroutines.*
1818
* // this code will not be cancelled
1919
* }
2020
* ```
21+
*
22+
* **WARNING**: This object is not designed to be used with [launch], [async], and other coroutine builders.
23+
* if you write `launch(NonCancellable) { ... }` then not only the newly launched job will not be cancelled
24+
* when the parent is cancelled, the whole parent-child relation between parent and child is severed.
25+
* The parent will not wait for the child's completion, nor will be cancelled when the child crashed.
2126
*/
2227
public object NonCancellable : AbstractCoroutineContextElement(Job), Job {
2328
/**

0 commit comments

Comments
 (0)