@@ -20,11 +20,8 @@ import kotlin.jvm.*
2020 * - A failure of a child job that was created using [launch][CoroutineScope.launch] can be handled via [CoroutineExceptionHandler] in the context.
2121 * - A failure of a child job that was created using [async][CoroutineScope.async] can be handled via [Deferred.await] on the resulting deferred value.
2222 *
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.
2825 */
2926@Suppress(" FunctionName" )
3027public fun SupervisorJob (parent : Job ? = null) : CompletableJob = SupervisorJobImpl (parent)
@@ -36,15 +33,16 @@ public fun SupervisorJob(parent: Job? = null) : CompletableJob = SupervisorJobIm
3633public fun SupervisorJob0 (parent : Job ? = null) : Job = SupervisorJob (parent)
3734
3835/* *
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].
4239 * This function returns as soon as the given block and all its child coroutines are completed.
4340 *
4441 * Unlike [coroutineScope], a failure of a child does not cause this scope to fail and does not affect its other children,
4542 * 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.
4846 *
4947 * The method may throw a [CancellationException] if the current job was cancelled externally,
5048 * or rethrow an exception thrown by the given [block].
0 commit comments