From 2ef69d49a1ee1071343914a28f726f6f927ab12e Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Fri, 11 Jun 2021 18:07:34 +0300 Subject: [PATCH 1/3] Update supervisorScope documentation to avoid confusion --- kotlinx-coroutines-core/common/src/Supervisor.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kotlinx-coroutines-core/common/src/Supervisor.kt b/kotlinx-coroutines-core/common/src/Supervisor.kt index 01a8e70522..c1852a8e3b 100644 --- a/kotlinx-coroutines-core/common/src/Supervisor.kt +++ b/kotlinx-coroutines-core/common/src/Supervisor.kt @@ -42,11 +42,15 @@ public fun SupervisorJob0(parent: Job? = null) : Job = SupervisorJob(parent) * Creates a [CoroutineScope] with [SupervisorJob] and calls the specified suspend block with this scope. * The provided scope inherits its [coroutineContext][CoroutineScope.coroutineContext] from the outer scope, but overrides * context's [Job] with [SupervisorJob]. + * This function returns as soon as the given block and all its children coroutines are completed. * - * A failure of a child does not cause this scope to fail and does not affect its other children, - * so a custom policy for handling failures of its children can be implemented. See [SupervisorJob] for details. - * A failure of the scope itself (exception thrown in the [block] or cancellation) fails the scope with all its children, + * Unlike [coroutineScope], a failure of a child does not cause this scope to fail and does not affect its other children, + * so a custom policy for handling failures of its children can be implemented. See [SupervisorJob] for additional details. + * A failure of the scope itself (exception thrown in the [block] or external cancellation) fails the scope with all its children, * but does not cancel parent job. + * + * The method may throw a [CancellationException] if the current job was cancelled externally, + * or the exception thrown by the given [block]. */ public suspend fun supervisorScope(block: suspend CoroutineScope.() -> R): R { contract { From b384b094d81881972e0eefaed29acc1e9840c1ac Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Wed, 16 Jun 2021 14:31:50 +0300 Subject: [PATCH 2/3] Update kotlinx-coroutines-core/common/src/Supervisor.kt Co-authored-by: dkhalanskyjb <52952525+dkhalanskyjb@users.noreply.github.com> --- kotlinx-coroutines-core/common/src/Supervisor.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlinx-coroutines-core/common/src/Supervisor.kt b/kotlinx-coroutines-core/common/src/Supervisor.kt index c1852a8e3b..58e5b57a38 100644 --- a/kotlinx-coroutines-core/common/src/Supervisor.kt +++ b/kotlinx-coroutines-core/common/src/Supervisor.kt @@ -42,7 +42,7 @@ public fun SupervisorJob0(parent: Job? = null) : Job = SupervisorJob(parent) * Creates a [CoroutineScope] with [SupervisorJob] and calls the specified suspend block with this scope. * The provided scope inherits its [coroutineContext][CoroutineScope.coroutineContext] from the outer scope, but overrides * context's [Job] with [SupervisorJob]. - * This function returns as soon as the given block and all its children coroutines are completed. + * This function returns as soon as the given block and all its child coroutines are completed. * * Unlike [coroutineScope], a failure of a child does not cause this scope to fail and does not affect its other children, * so a custom policy for handling failures of its children can be implemented. See [SupervisorJob] for additional details. From 7c51534483bcdf40a1504f95199a71a5a73fac8e Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Wed, 16 Jun 2021 14:31:58 +0300 Subject: [PATCH 3/3] Update kotlinx-coroutines-core/common/src/Supervisor.kt Co-authored-by: dkhalanskyjb <52952525+dkhalanskyjb@users.noreply.github.com> --- kotlinx-coroutines-core/common/src/Supervisor.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlinx-coroutines-core/common/src/Supervisor.kt b/kotlinx-coroutines-core/common/src/Supervisor.kt index 58e5b57a38..8411c5c65a 100644 --- a/kotlinx-coroutines-core/common/src/Supervisor.kt +++ b/kotlinx-coroutines-core/common/src/Supervisor.kt @@ -50,7 +50,7 @@ public fun SupervisorJob0(parent: Job? = null) : Job = SupervisorJob(parent) * but does not cancel parent job. * * The method may throw a [CancellationException] if the current job was cancelled externally, - * or the exception thrown by the given [block]. + * or rethrow an exception thrown by the given [block]. */ public suspend fun supervisorScope(block: suspend CoroutineScope.() -> R): R { contract {