Skip to content

Commit 93a9674

Browse files
qwwdfsaddkhalanskyjb
authored andcommitted
Update supervisorScope documentation to avoid confusion (Kotlin#2757)
* Update supervisorScope documentation to avoid confusion Co-authored-by: dkhalanskyjb <[email protected]>
1 parent 2333070 commit 93a9674

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

kotlinx-coroutines-core/common/src/Supervisor.kt

+7-3
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,15 @@ public fun SupervisorJob0(parent: Job? = null) : Job = SupervisorJob(parent)
4242
* Creates a [CoroutineScope] with [SupervisorJob] and calls the specified suspend block with this scope.
4343
* The provided scope inherits its [coroutineContext][CoroutineScope.coroutineContext] from the outer scope, but overrides
4444
* context's [Job] with [SupervisorJob].
45+
* This function returns as soon as the given block and all its child coroutines are completed.
4546
*
46-
* A failure of a child does not cause this scope to fail and does not affect its other children,
47-
* so a custom policy for handling failures of its children can be implemented. See [SupervisorJob] for details.
48-
* A failure of the scope itself (exception thrown in the [block] or cancellation) fails the scope with all its children,
47+
* Unlike [coroutineScope], a failure of a child does not cause this scope to fail and does not affect its other children,
48+
* so a custom policy for handling failures of its children can be implemented. See [SupervisorJob] for additional details.
49+
* A failure of the scope itself (exception thrown in the [block] or external cancellation) fails the scope with all its children,
4950
* but does not cancel parent job.
51+
*
52+
* The method may throw a [CancellationException] if the current job was cancelled externally,
53+
* or rethrow an exception thrown by the given [block].
5054
*/
5155
public suspend fun <R> supervisorScope(block: suspend CoroutineScope.() -> R): R {
5256
contract {

0 commit comments

Comments
 (0)