Skip to content

Commit 149ba48

Browse files
qwwdfsadelizarov
authored andcommitted
Following internal API is removed from public declarations:
* ArrayBroadcastChannel * NonDisposableHandle * handleCoroutineException * JobCancellationException * withTimeout and delay with TimeUnit
1 parent a2d8088 commit 149ba48

File tree

19 files changed

+31
-38
lines changed

19 files changed

+31
-38
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import kotlin.coroutines.experimental.*
1414
* **Note: cannot be internal until we get rid of MutableDelegateContinuation in IO**
1515
*
1616
* @param cause the exceptional completion cause. It's either original exceptional cause
17-
* or artificial JobCancellationException if no cause was provided
17+
* or artificial [CancellationException] if no cause was provided
1818
* @suppress **This is unstable API and it is subject to change.**
1919
*/
2020
open class CompletedExceptionally(
@@ -29,7 +29,7 @@ open class CompletedExceptionally(
2929
* **Note: This class cannot be used outside of internal coroutines framework**.
3030
*
3131
* @param job the job that was cancelled.
32-
* @param cause the exceptional completion cause. If `cause` is null, then a [JobCancellationException] is created.
32+
* @param cause the exceptional completion cause. If `cause` is null, then a [CancellationException] is created.
3333
* @suppress **This is unstable API and it is subject to change.**
3434
*/
3535
internal class Cancelled(
@@ -43,8 +43,8 @@ internal class Cancelled(
4343
* **Note: This class cannot be used outside of internal coroutines framework**.
4444
*
4545
* @param continuation the continuation that was cancelled.
46-
* @param cause the exceptional completion cause. If `cause` is null, then a [JobCancellationException]
47-
* if created on first get from [exception] property.
46+
* @param cause the exceptional completion cause. If `cause` is null, then a [CancellationException]
47+
* if created on first access to [exception] property.
4848
* @suppress **This is unstable API and it is subject to change.**
4949
*/
5050
public class CancelledContinuation(

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal expect fun handleCoroutineExceptionImpl(context: CoroutineContext, exce
2222
* Otherwise all instances of [CoroutineExceptionHandler] found via [ServiceLoader] and [Thread.uncaughtExceptionHandler] are invoked
2323
*/
2424
@JvmOverloads // binary compatibility
25-
@InternalCoroutinesApi // todo: review KDoc use
25+
@InternalCoroutinesApi
2626
public fun handleCoroutineException(context: CoroutineContext, exception: Throwable, caller: Job? = null) {
2727
// if exception handling fails, make sure the original exception is not lost
2828
try {
@@ -72,11 +72,9 @@ public inline fun CoroutineExceptionHandler(crossinline handler: (CoroutineConte
7272
* (because that is the supposed mechanism to cancel the running coroutine)
7373
* * Otherwise:
7474
* * if there is a [Job] in the context, then [Job.cancel] is invoked;
75-
* * all instances of [CoroutineExceptionHandler] found via [ServiceLoader] are invoked;
76-
* * and current thread's [Thread.uncaughtExceptionHandler] is invoked.
77-
*
78-
* See [handleCoroutineException].
79-
*/
75+
* * Otherwise, all instances of [CoroutineExceptionHandler] found via [ServiceLoader]
76+
* * and current thread's [Thread.uncaughtExceptionHandler] are invoked.
77+
**/
8078
public interface CoroutineExceptionHandler : CoroutineContext.Element {
8179
/**
8280
* Key for [CoroutineExceptionHandler] instance in the coroutine context.
@@ -85,7 +83,7 @@ public interface CoroutineExceptionHandler : CoroutineContext.Element {
8583

8684
/**
8785
* Handles uncaught [exception] in the given [context]. It is invoked
88-
* if coroutine has an uncaught exception. See [handleCoroutineException].
86+
* if coroutine has an uncaught exception.
8987
*/
9088
public fun handleException(context: CoroutineContext, exception: Throwable)
9189
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ object GlobalScope : CoroutineScope {
169169
* 2) If `doSomeWork` throws an exception, then `async` task is cancelled and `loadDataForUI` rethrows that exception.
170170
* 3) If outer scope of `loadDataForUI` is cancelled, both started `async` and `withContext` are cancelled.
171171
*
172-
* Method may throw [JobCancellationException] if the current job was cancelled externally
172+
* Method may throw [CancellationException] if the current job was cancelled externally
173173
* or may throw the corresponding unhandled [Throwable] if there is any unhandled exception in this scope
174174
* (for example, from a crashed coroutine that was started with [launch][CoroutineScope.launch] in this scope).
175175
*/

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ public suspend fun delay(timeMillis: Long) {
109109
*
110110
* @suppress **Deprecated**: Replace with `delay(unit.toMillis(time))`
111111
*/
112-
// todo: review usage in Guides and samples
113112
@Deprecated(
114113
message = "Replace with delay(unit.toMillis(time))",
115114
replaceWith = ReplaceWith("delay(unit.toMillis(time))")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public expect open class CancellationException(message: String?) : IllegalStateE
1212
/**
1313
* @suppress **Deprecated**: Replace with [CancellationException].
1414
*/
15-
@InternalCoroutinesApi // todo: review usage from docs and examples
15+
@InternalCoroutinesApi
1616
@Deprecated(message = "Replace with CancellationException", replaceWith = ReplaceWith("CancellationException"))
1717
public expect class JobCancellationException(
1818
message: String,

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ public interface Job : CoroutineContext.Element {
123123
*
124124
* This function returns the original [cancel] cause of this job if that `cause` was an instance of
125125
* [CancellationException]. Otherwise (if this job was cancelled with a cause of a different type, or
126-
* was cancelled without a cause, or had completed normally), an instance of [JobCancellationException] is
127-
* returned. The [JobCancellationException.cause] of the resulting [JobCancellationException] references
126+
* was cancelled without a cause, or had completed normally), an instance of [CancellationException] is
127+
* returned. The [CancellationException.cause] of the resulting [CancellationException] references
128128
* the original cancellation cause that was passed to [cancel] function.
129129
*
130130
* This function throws [IllegalStateException] when invoked on a job that has not
@@ -333,8 +333,8 @@ public interface Job : CoroutineContext.Element {
333333
* @param onCancelling when `true`, then the [handler] is invoked as soon as this job transitions to _cancelling_ state;
334334
* when `false` then the [handler] is invoked only when it transitions to _completed_ state.
335335
* @param invokeImmediately when `true` and this job is already in the desired state (depending on [onCancelling]),
336-
* then the [handler] is immediately and synchronously invoked and [NonDisposableHandle] is returned;
337-
* when `false` then [NonDisposableHandle] is returned, but the [handler] is not invoked.
336+
* then the [handler] is immediately and synchronously invoked and no-op [DisposableHandle] is returned;
337+
* when `false` then no-op [DisposableHandle] is returned, but the [handler] is not invoked.
338338
* @param handler the handler.
339339
*
340340
* @suppress **This an internal API and should not be used from general code.**
@@ -531,7 +531,7 @@ public suspend fun Job.join() = this.join()
531531
* No-op implementation of [DisposableHandle].
532532
* @suppress **This an internal API and should not be used from general code.**
533533
*/
534-
@InternalCoroutinesApi // todo: review references from KDocs
534+
@InternalCoroutinesApi
535535
public object NonDisposableHandle : DisposableHandle {
536536
/** Does not do anything. */
537537
override fun dispose() {}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ internal open class JobSupport constructor(active: Boolean) : Job, SelectClause0
406406

407407
/**
408408
* Returns the cause that signals the completion of this job -- it returns the original
409-
* [cancel] cause, [JobCancellationException] or **`null` if this job had completed normally**.
409+
* [cancel] cause, [CancellationException] or **`null` if this job had completed normally**.
410410
* This function throws [IllegalStateException] when invoked for an job that has not [completed][isCompleted] nor
411411
* [isCancelled] yet.
412412
*/

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ public object NonCancellable : AbstractCoroutineContextElement(Job), Job {
7272
override fun getCancellationException(): CancellationException = throw IllegalStateException("This job is always active")
7373

7474
/**
75-
* Always returns [NonDisposableHandle].
7675
* @suppress **This an internal API and should not be used from general code.**
7776
*/
7877
@Suppress("OverridingDeprecatedMember")
@@ -81,7 +80,6 @@ public object NonCancellable : AbstractCoroutineContextElement(Job), Job {
8180
NonDisposableHandle
8281

8382
/**
84-
* Always returns [NonDisposableHandle].
8583
* @suppress **This an internal API and should not be used from general code.**
8684
*/
8785
@Suppress("OverridingDeprecatedMember")
@@ -90,7 +88,7 @@ public object NonCancellable : AbstractCoroutineContextElement(Job), Job {
9088
NonDisposableHandle
9189

9290
/**
93-
* Always returns [NonDisposableHandle].
91+
* Always returns no-op handle.
9492
* @suppress **This an internal API and should not be used from general code.**
9593
*/
9694
@Suppress("OverridingDeprecatedMember")
@@ -99,7 +97,7 @@ public object NonCancellable : AbstractCoroutineContextElement(Job), Job {
9997
NonDisposableHandle
10098

10199
/**
102-
* Always returns [NonDisposableHandle].
100+
* Always returns no-op handle.
103101
* @suppress **This an internal API and should not be used from general code.**
104102
*/
105103
@InternalCoroutinesApi
@@ -129,7 +127,7 @@ public object NonCancellable : AbstractCoroutineContextElement(Job), Job {
129127
get() = emptySequence()
130128

131129
/**
132-
* Always returns [NonDisposableHandle] and does not do anything.
130+
* Always returns no-op handle and does not do anything.
133131
* @suppress **This an internal API and should not be used from general code.**
134132
*/
135133
@Suppress("OverridingDeprecatedMember")

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public suspend fun <T> withTimeout(time: Int, block: suspend CoroutineScope.() -
3131
*
3232
* @suppress **Deprecated**: Replace with `withTimeout(unit.toMillis(time), block)`
3333
*/
34-
// todo: review usage in Guides and samples
3534
@Deprecated(
3635
message = "Replace with withTimeout(unit.toMillis(time), block)",
3736
replaceWith = ReplaceWith("withTimeout(unit.toMillis(time), block)")
@@ -62,7 +61,6 @@ public suspend fun <T> withTimeoutOrNull(time: Int, block: suspend CoroutineScop
6261
* @param unit timeout unit (milliseconds by default)
6362
* @suppress **Deprecated**: Replace with `withTimeoutOrNull(unit.toMillis(time), block)`
6463
*/
65-
// todo: review usage in Guides and samples
6664
@Deprecated(
6765
message = "Replace with withTimeoutOrNull(unit.toMillis(time), block)",
6866
replaceWith = ReplaceWith("withTimeoutOrNull(unit.toMillis(time), block)")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import kotlinx.coroutines.experimental.selects.*
2424
*
2525
* @suppress **This an internal API and should not be used from general code.**
2626
*/
27-
@InternalCoroutinesApi // todo: review KDoc refs
27+
@InternalCoroutinesApi
2828
public class ArrayBroadcastChannel<E>
2929
@Deprecated(
3030
"Replace with BroadcastChannel factory function",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public fun <E> broadcast(
6666
* the resulting channel becomes _failed_, so that any attempt to receive from such a channel throws exception.
6767
*
6868
* The kind of the resulting channel depends on the specified [capacity] parameter:
69-
* * when `capacity` positive (1 by default), but less than [UNLIMITED] -- uses [ArrayBroadcastChannel]
69+
* * when `capacity` positive (1 by default), but less than [UNLIMITED] -- uses `ArrayBroadcastChannel` with a buffer of given capacity,
7070
* * when `capacity` is [CONFLATED] -- uses [ConflatedBroadcastChannel] that conflates back-to-back sends;
7171
* * otherwise -- throws [IllegalArgumentException].
7272
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public interface BroadcastChannel<E> : SendChannel<E> {
7373
* Creates a broadcast channel with the specified buffer capacity.
7474
*
7575
* The resulting channel type depends on the specified [capacity] parameter:
76-
* * when `capacity` positive, but less than [UNLIMITED] -- creates [ArrayBroadcastChannel]
76+
* * when `capacity` positive, but less than [UNLIMITED] -- creates `ArrayBroadcastChannel` with a buffer of given capacity.
7777
* **Note:** this channel looses all items that are send to it until the first subscriber appears;
7878
* * when `capacity` is [CONFLATED] -- creates [ConflatedBroadcastChannel] that conflates back-to-back sends;
7979
* * otherwise -- throws [IllegalArgumentException].

common/kotlinx-coroutines-core-common/src/internal/Concurrent.common.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package kotlinx.coroutines.experimental.internal
66

77
/**
8-
* Special kind of list intended to be used as collection of subscribers in [ArrayBroadcastChannel]
8+
* Special kind of list intended to be used as collection of subscribers in `ArrayBroadcastChannel`
99
* On JVM it's CopyOnWriteList and on JS it's MutableList.
1010
*
1111
* Note that this alias is intentionally not named as CopyOnWriteList to avoid accidental misusage outside of ArrayBroadcastChannel

common/kotlinx-coroutines-core-common/test/CoroutinesTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class CoroutinesTest : TestBase() {
238238
// now we have a failed job with TestException
239239
finish(3)
240240
try {
241-
job.cancelAndJoin() // join should crash on child's exception but it will be wrapped into JobCancellationException
241+
job.cancelAndJoin() // join should crash on child's exception but it will be wrapped into CancellationException
242242
} catch (e: Throwable) {
243243
e as CancellationException // type assertion
244244
assertTrue(e.cause is TestException)

core/kotlinx-coroutines-core/src/Builders.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import kotlin.coroutines.experimental.*
2828
*
2929
* See [newCoroutineContext][CoroutineScope.newCoroutineContext] for a description of debugging facilities that are available for newly created coroutine.
3030
*
31-
* @param context context of the coroutine. The default value is an implementation of [EventLoop].
31+
* @param context context of the coroutine. The default value is an event loop on current thread.
3232
* @param block the coroutine code.
3333
*/
3434
@Throws(InterruptedException::class)

core/kotlinx-coroutines-core/src/Exceptions.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public actual class CompletionHandlerException actual constructor(
1919
* Thrown by cancellable suspending functions if the [Job] of the coroutine is cancelled while it is suspending.
2020
* It indicates _normal_ cancellation of a coroutine.
2121
* **It is not printed to console/log by default uncaught exception handler**.
22-
* (see [handleCoroutineException]).
22+
* See [CoroutineExceptionHandler]
2323
*/
2424
public actual typealias CancellationException = java.util.concurrent.CancellationException
2525

@@ -30,7 +30,7 @@ public actual typealias CancellationException = java.util.concurrent.Cancellatio
3030
*
3131
* @suppress **Deprecated**: Replace with [CancellationException].
3232
*/
33-
@InternalCoroutinesApi // todo: review usage from docs and examples
33+
@InternalCoroutinesApi
3434
@Deprecated(message = "Replace with CancellationException", replaceWith = ReplaceWith("CancellationException"))
3535
public actual class JobCancellationException public actual constructor(
3636
message: String,

integration/kotlinx-coroutines-jdk8/test/examples/simple-example-2.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import java.util.concurrent.*
1111
// this function returns a CompletableFuture using Kotlin coroutines
1212
fun supplyTheAnswerAsync(): CompletableFuture<Int> = GlobalScope.future {
1313
println("We might be doing some asynchronous IO here or something else...")
14-
delay(1, TimeUnit.SECONDS) // just do a non-blocking delay
14+
delay(1000) // just do a non-blocking delay
1515
42 // The answer!
1616
}
1717

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public actual class CompletionHandlerException public actual constructor(
1616
* Thrown by cancellable suspending functions if the [Job] of the coroutine is cancelled while it is suspending.
1717
* It indicates _normal_ cancellation of a coroutine.
1818
* **It is not printed to console/log by default uncaught exception handler**.
19-
* (see [handleCoroutineException]).
19+
* (see [CoroutineExceptionHandler]).
2020
*/
2121
public actual open class CancellationException actual constructor(message: String?) : IllegalStateException(message)
2222

native/kotlinx-coroutines-core-native/src/Exceptions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public actual class CompletionHandlerException public actual constructor(
1616
* Thrown by cancellable suspending functions if the [Job] of the coroutine is cancelled while it is suspending.
1717
* It indicates _normal_ cancellation of a coroutine.
1818
* **It is not printed to console/log by default uncaught exception handler**.
19-
* (see [handleCoroutineException]).
19+
* (see [CoroutineExceptionHandler]).
2020
*/
2121
public actual open class CancellationException actual constructor(message: String?) : IllegalStateException(message)
2222

0 commit comments

Comments
 (0)