@@ -20,11 +20,8 @@ import kotlin.jvm.*
20
20
* - A failure of a child job that was created using [launch][CoroutineScope.launch] can be handled via [CoroutineExceptionHandler] in the context.
21
21
* - A failure of a child job that was created using [async][CoroutineScope.async] can be handled via [Deferred.await] on the resulting deferred value.
22
22
*
23
- * If [parent] job is specified, then this supervisor job becomes a child job of its parent and is cancelled when its
24
- * parent fails or is cancelled. All this supervisor's children are cancelled in this case, too. The invocation of
25
- * [cancel][Job.cancel] with exception (other than [CancellationException]) on this supervisor job also cancels parent.
26
- *
27
- * @param parent an optional parent job.
23
+ * If a [parent] job is specified, then this supervisor job becomes a child job of [parent] and is cancelled when the
24
+ * parent fails or is cancelled. All this supervisor's children are cancelled in this case, too.
28
25
*/
29
26
@Suppress(" FunctionName" )
30
27
public fun SupervisorJob (parent : Job ? = null) : CompletableJob = SupervisorJobImpl (parent)
@@ -36,15 +33,16 @@ public fun SupervisorJob(parent: Job? = null) : CompletableJob = SupervisorJobIm
36
33
public fun SupervisorJob0 (parent : Job ? = null) : Job = SupervisorJob (parent)
37
34
38
35
/* *
39
- * Creates a [CoroutineScope] with [SupervisorJob] and calls the specified suspend block with this scope.
40
- * The provided scope inherits its [coroutineContext][CoroutineScope.coroutineContext] from the outer scope, but overrides
41
- * context's [Job] with [SupervisorJob].
36
+ * Creates a [CoroutineScope] with [SupervisorJob] and calls the specified suspend [ block] with this scope.
37
+ * The provided scope inherits its [coroutineContext][CoroutineScope.coroutineContext] from the outer scope, using the
38
+ * [Job] from that context as the parent for the new [SupervisorJob].
42
39
* This function returns as soon as the given block and all its child coroutines are completed.
43
40
*
44
41
* Unlike [coroutineScope], a failure of a child does not cause this scope to fail and does not affect its other children,
45
42
* so a custom policy for handling failures of its children can be implemented. See [SupervisorJob] for additional details.
46
- * A failure of the scope itself (exception thrown in the [block] or external cancellation) fails the scope with all its children,
47
- * but does not cancel parent job.
43
+ *
44
+ * If an exception happened in [block], then the supervisor job is failed and all its children are cancelled.
45
+ * If the current coroutine was cancelled, then both the supervisor job itself and all its children are cancelled.
48
46
*
49
47
* The method may throw a [CancellationException] if the current job was cancelled externally,
50
48
* or rethrow an exception thrown by the given [block].
0 commit comments