Skip to content

Commit 17bae3f

Browse files
committed
Don't say that job completion causes CancellationException
What does it even mean?
1 parent 92df6e1 commit 17bae3f

File tree

18 files changed

+63
-63
lines changed

18 files changed

+63
-63
lines changed

integration/kotlinx-coroutines-guava/src/ListenableFuture.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public fun <T> Deferred<T>.asListenableFuture(): ListenableFuture<T> {
216216
*
217217
* This suspend function is cancellable.
218218
*
219-
* If the [Job] of the current coroutine is cancelled or completed while this suspending function is waiting, this function
219+
* If the [Job] of the current coroutine is cancelled while this suspending function is waiting, this function
220220
* stops waiting for the future and immediately resumes with [CancellationException][kotlinx.coroutines.CancellationException].
221221
*
222222
* This method is intended to be used with one-shot Futures, so on coroutine cancellation, the Future is cancelled as well.

integration/kotlinx-coroutines-play-services/src/Tasks.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private fun <T> Task<T>.asDeferredImpl(cancellationTokenSource: CancellationToke
9494
* Awaits the completion of the task without blocking a thread.
9595
*
9696
* This suspending function is cancellable.
97-
* If the [Job] of the current coroutine is cancelled or completed while this suspending function is waiting, this function
97+
* If the [Job] of the current coroutine is cancelled while this suspending function is waiting, this function
9898
* stops waiting for the completion stage and immediately resumes with [CancellationException].
9999
*
100100
* For bi-directional cancellation, an overload that accepts [CancellationTokenSource] can be used.
@@ -105,7 +105,7 @@ public suspend fun <T> Task<T>.await(): T = awaitImpl(null)
105105
* Awaits the completion of the task that is linked to the given [CancellationTokenSource] to control cancellation.
106106
*
107107
* This suspending function is cancellable and cancellation is bi-directional:
108-
* - If the [Job] of the current coroutine is cancelled or completed while this suspending function is waiting, this function
108+
* - If the [Job] of the current coroutine is cancelled while this suspending function is waiting, this function
109109
* cancels the [cancellationTokenSource] and throws a [CancellationException].
110110
* - If the task is cancelled, then this function will throw a [CancellationException].
111111
*

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import kotlin.coroutines.*
1111
* This function is **not** equivalent to `deferreds.map { it.await() }` which fails only when it sequentially
1212
* gets to wait for the failing deferred, while this `awaitAll` fails immediately as soon as any of the deferreds fail.
1313
*
14-
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled or completed while this
14+
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled while this
1515
* suspending function is waiting, this function immediately resumes with [CancellationException].
1616
* There is a **prompt cancellation guarantee**: even if this function is ready to return the result, but was cancelled
1717
* while suspended, [CancellationException] will be thrown. See [suspendCancellableCoroutine] for low-level details.
@@ -27,7 +27,7 @@ public suspend fun <T> awaitAll(vararg deferreds: Deferred<T>): List<T> =
2727
* This function is **not** equivalent to `this.map { it.await() }` which fails only when it sequentially
2828
* gets to wait for the failing deferred, while this `awaitAll` fails immediately as soon as any of the deferreds fail.
2929
*
30-
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled or completed while this
30+
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled while this
3131
* suspending function is waiting, this function immediately resumes with [CancellationException].
3232
* There is a **prompt cancellation guarantee**: even if this function is ready to return the result, but was cancelled
3333
* while suspended, [CancellationException] will be thrown. See [suspendCancellableCoroutine] for low-level details.
@@ -39,7 +39,7 @@ public suspend fun <T> Collection<Deferred<T>>.awaitAll(): List<T> =
3939
* Suspends current coroutine until all given jobs are complete.
4040
* This method is semantically equivalent to joining all given jobs one by one with `jobs.forEach { it.join() }`.
4141
*
42-
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled or completed while this
42+
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled while this
4343
* suspending function is waiting, this function immediately resumes with [CancellationException].
4444
* There is a **prompt cancellation guarantee**: even if this function is ready to return the result, but was cancelled
4545
* while suspended, [CancellationException] will be thrown. See [suspendCancellableCoroutine] for low-level details.
@@ -50,7 +50,7 @@ public suspend fun joinAll(vararg jobs: Job): Unit = jobs.forEach { it.join() }
5050
* Suspends current coroutine until all given jobs are complete.
5151
* This method is semantically equivalent to joining all given jobs one by one with `forEach { it.join() }`.
5252
*
53-
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled or completed while this
53+
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled while this
5454
* suspending function is waiting, this function immediately resumes with [CancellationException].
5555
* There is a **prompt cancellation guarantee**: even if this function is ready to return the result, but was cancelled
5656
* while suspended, [CancellationException] will be thrown. See [suspendCancellableCoroutine] for low-level details.

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public suspend fun awaitCancellation(): Nothing = suspendCancellableCoroutine {}
106106
* Delays coroutine for at least the given time without blocking a thread and resumes it after a specified time.
107107
* If the given [timeMillis] is non-positive, this function returns immediately.
108108
*
109-
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled or completed while this
109+
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled while this
110110
* suspending function is waiting, this function immediately resumes with [CancellationException].
111111
* There is a **prompt cancellation guarantee**: even if this function is ready to return the result, but was cancelled
112112
* while suspended, [CancellationException] will be thrown. See [suspendCancellableCoroutine] for low-level details.
@@ -132,7 +132,7 @@ public suspend fun delay(timeMillis: Long) {
132132
* Delays coroutine for at least the given [duration] without blocking a thread and resumes it after the specified time.
133133
* If the given [duration] is non-positive, this function returns immediately.
134134
*
135-
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled or completed while this
135+
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled while this
136136
* suspending function is waiting, this function immediately resumes with [CancellationException].
137137
* There is a **prompt cancellation guarantee**: even if this function is ready to return the result, but was cancelled
138138
* while suspended, [CancellationException] will be thrown. See [suspendCancellableCoroutine] for low-level details.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import kotlin.coroutines.intrinsics.*
77
* Yields the thread (or thread pool) of the current coroutine dispatcher
88
* to other coroutines on the same dispatcher to run if possible.
99
*
10-
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled or completed while
10+
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled while
1111
* [yield] is invoked or while waiting for dispatch, it immediately resumes with [CancellationException].
1212
* There is a **prompt cancellation guarantee**: even if this function is ready to return the result, but was cancelled
1313
* while suspended, [CancellationException] will be thrown. See [suspendCancellableCoroutine] for low-level details.

kotlinx-coroutines-core/common/src/channels/Channel.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public interface SendChannel<in E> {
4141
* All elements sent over the channel are delivered in first-in first-out order. The sent element
4242
* will be delivered to receivers before the close token.
4343
*
44-
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled or completed while this
44+
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled while this
4545
* suspending function is waiting, this function immediately resumes with [CancellationException].
4646
* There is a **prompt cancellation guarantee**: even if [send] managed to send the element, but was cancelled
4747
* while suspended, [CancellationException] will be thrown. See [suspendCancellableCoroutine] for low-level details.
@@ -212,14 +212,14 @@ public interface ReceiveChannel<out E> {
212212
* If the channel was closed because of an exception, it is called a _failed_ channel and this function
213213
* will throw the original [close][SendChannel.close] cause exception.
214214
*
215-
* This suspending function is cancellable. If the [Job] of the current coroutine is cancelled or completed while this
215+
* This suspending function is cancellable. If the [Job] of the current coroutine is cancelled while this
216216
* function is suspended, this function immediately resumes with a [CancellationException].
217217
* There is a **prompt cancellation guarantee**. If the job was cancelled while this function was
218218
* suspended, it will not resume successfully. The `receive` call can retrieve the element from the channel,
219219
* but then throw [CancellationException], thus failing to deliver the element.
220220
* See "Undelivered elements" section in [Channel] documentation for details on handling undelivered elements.
221221
*
222-
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled or completed while this
222+
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled while this
223223
* suspending function is waiting, this function immediately resumes with [CancellationException].
224224
* There is a **prompt cancellation guarantee**: even if [receive] managed to retrieve the element from the channel,
225225
* but was cancelled while suspended, [CancellationException] will be thrown.
@@ -250,7 +250,7 @@ public interface ReceiveChannel<out E> {
250250
* or the close cause if the channel was closed. Closed cause may be `null` if the channel was closed normally.
251251
* The result cannot be [failed][ChannelResult.isFailure] without being [closed][ChannelResult.isClosed].
252252
*
253-
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled or completed while this
253+
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled while this
254254
* suspending function is waiting, this function immediately resumes with [CancellationException].
255255
* There is a **prompt cancellation guarantee**: even if [receiveCatching] managed to retrieve the element from the
256256
* channel, but was cancelled while suspended, [CancellationException] will be thrown.
@@ -573,7 +573,7 @@ public interface ChannelIterator<out E> {
573573
* This function retrieves and removes an element from this channel for the subsequent invocation
574574
* of [next].
575575
*
576-
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled or completed while this
576+
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled while this
577577
* suspending function is waiting, this function immediately resumes with [CancellationException].
578578
* There is a **prompt cancellation guarantee**: even if [hasNext] retrieves the element from the channel during
579579
* its operation, but was cancelled while suspended, [CancellationException] will be thrown.

kotlinx-coroutines-core/common/src/channels/Produce.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public interface ProducerScope<in E> : CoroutineScope, SendChannel<E> {
2222
* Suspends the current coroutine until the channel is either [closed][SendChannel.close] or [cancelled][ReceiveChannel.cancel]
2323
* and invokes the given [block] before resuming the coroutine.
2424
*
25-
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled or completed while this
25+
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled while this
2626
* suspending function is waiting, this function immediately resumes with [CancellationException].
2727
* There is a **prompt cancellation guarantee**: even if this function is ready to return, but was cancelled
2828
* while suspended, [CancellationException] will be thrown. See [suspendCancellableCoroutine] for low-level details.

kotlinx-coroutines-core/common/src/selects/Select.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import kotlin.jvm.*
3838
* | [ReceiveChannel] | [receiveCatching][ReceiveChannel.receiveCatching] | [onReceiveCatching][ReceiveChannel.onReceiveCatching]
3939
* | none | [delay] | [onTimeout][SelectBuilder.onTimeout]
4040
*
41-
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled or completed while this
41+
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled while this
4242
* suspending function is waiting, this function immediately resumes with [CancellationException].
4343
* There is a **prompt cancellation guarantee**: even if this function is ready to return the result, but was cancelled
4444
* while suspended, [CancellationException] will be thrown. See [suspendCancellableCoroutine] for low-level details.

kotlinx-coroutines-core/common/src/sync/Mutex.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public interface Mutex {
4040
/**
4141
* Locks this mutex, suspending caller until the lock is acquired (in other words, while the lock is held elsewhere).
4242
*
43-
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled or completed while this
43+
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled while this
4444
* suspending function is waiting, this function immediately resumes with [CancellationException].
4545
* There is a **prompt cancellation guarantee**: even if this function is ready to return the result, but was cancelled
4646
* while suspended, [CancellationException] will be thrown. See [suspendCancellableCoroutine] for low-level details.

kotlinx-coroutines-core/common/src/sync/Semaphore.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public interface Semaphore {
2828
* Acquires a permit from this semaphore, suspending until one is available.
2929
* All suspending acquirers are processed in first-in-first-out (FIFO) order.
3030
*
31-
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled or completed while this
31+
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled while this
3232
* suspending function is waiting, this function immediately resumes with [CancellationException].
3333
* There is a **prompt cancellation guarantee**: even if this function is ready to return the result, but was cancelled
3434
* while suspended, [CancellationException] will be thrown. See [suspendCancellableCoroutine] for low-level details.

kotlinx-coroutines-core/jdk8/src/future/Future.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public fun <T> CompletionStage<T>.asDeferred(): Deferred<T> {
146146
* Awaits for completion of [CompletionStage] without blocking a thread.
147147
*
148148
* This suspending function is cancellable.
149-
* If the [Job] of the current coroutine is cancelled or completed while this suspending function is waiting, this function
149+
* If the [Job] of the current coroutine is cancelled while this suspending function is waiting, this function
150150
* stops waiting for the completion stage and immediately resumes with [CancellationException][kotlinx.coroutines.CancellationException].
151151
*
152152
* This method is intended to be used with one-shot futures, so on coroutine cancellation the [CompletableFuture] that

kotlinx-coroutines-core/js/src/Promise.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public fun <T> Promise<T>.asDeferred(): Deferred<T> {
5555
/**
5656
* Awaits for completion of the promise without blocking.
5757
*
58-
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled or completed while this
58+
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled while this
5959
* suspending function is waiting on the promise, this function immediately resumes with [CancellationException].
6060
* There is a **prompt cancellation guarantee**: even if this function is ready to return the result, but was cancelled
6161
* while suspended, [CancellationException] will be thrown. See [suspendCancellableCoroutine] for low-level details.

kotlinx-coroutines-core/wasmJs/src/Promise.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public fun <T> Promise<JsAny?>.asDeferred(): Deferred<T> {
6666
/**
6767
* Awaits for completion of the promise without blocking.
6868
*
69-
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled or completed while this
69+
* This suspending function is cancellable: if the [Job] of the current coroutine is cancelled while this
7070
* suspending function is waiting on the promise, this function immediately resumes with [CancellationException].
7171
* There is a **prompt cancellation guarantee**: even if this function is ready to return the result, but was cancelled
7272
* while suspended, [CancellationException] will be thrown. See [suspendCancellableCoroutine] for low-level details.

0 commit comments

Comments
 (0)