Skip to content

Commit 1f7b2d8

Browse files
committed
Make all API internal where it is possible
1 parent d92b0fa commit 1f7b2d8

File tree

49 files changed

+69
-563
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+69
-563
lines changed

benchmarks/src/jmh/kotlin/benchmarks/ForkJoinBenchmark.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ open class ForkJoinBenchmark : ParametrizedDispatcherBase() {
5454

5555
@Benchmark
5656
fun asyncFjp() = runBlocking {
57-
CoroutineScope(CommonPool).startAsync(coefficients, 0, coefficients.size).await()
57+
CoroutineScope(ForkJoinPool.commonPool().asCoroutineDispatcher()).startAsync(coefficients, 0, coefficients.size).await()
5858
}
5959

6060
@Benchmark

benchmarks/src/jmh/kotlin/benchmarks/ParametrizedDispatcherBase.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import org.openjdk.jmh.annotations.Param
1111
import org.openjdk.jmh.annotations.Setup
1212
import org.openjdk.jmh.annotations.TearDown
1313
import java.io.Closeable
14+
import java.util.concurrent.*
1415
import kotlin.coroutines.CoroutineContext
1516

1617
/**
@@ -26,7 +27,7 @@ abstract class ParametrizedDispatcherBase : CoroutineScope {
2627
@Setup
2728
open fun setup() {
2829
coroutineContext = when {
29-
dispatcher == "fjp" -> CommonPool
30+
dispatcher == "fjp" -> ForkJoinPool.commonPool().asCoroutineDispatcher()
3031
dispatcher == "experimental" -> {
3132
ExperimentalCoroutineDispatcher(CORES_COUNT).also { closeable = it }
3233
}

benchmarks/src/jmh/kotlin/benchmarks/actors/PingPongWithBlockingContext.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ open class PingPongWithBlockingContext {
4949

5050
@Benchmark
5151
fun commonPoolWithContextPingPong() = runBlocking {
52-
runPingPongs(CommonPool, threadPool)
52+
runPingPongs(ForkJoinPool.commonPool().asCoroutineDispatcher(), threadPool)
5353
}
5454

5555
private suspend fun runPingPongs(pingContext: CoroutineContext, pongContext: CoroutineContext) {

binary-compatibility-validator/reference-public-api/kotlinx-coroutines-android.txt

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
public final class kotlinx/coroutines/android/HandlerContext : kotlinx/coroutines/android/HandlerDispatcher, kotlinx/coroutines/Delay {
2-
public fun <init> (Landroid/os/Handler;Ljava/lang/String;)V
3-
public synthetic fun <init> (Landroid/os/Handler;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
4-
public fun dispatch (Lkotlin/coroutines/CoroutineContext;Ljava/lang/Runnable;)V
5-
public fun equals (Ljava/lang/Object;)Z
6-
public synthetic fun getImmediate ()Lkotlinx/coroutines/MainCoroutineDispatcher;
7-
public fun getImmediate ()Lkotlinx/coroutines/android/HandlerContext;
8-
public synthetic fun getImmediate ()Lkotlinx/coroutines/android/HandlerDispatcher;
9-
public fun hashCode ()I
10-
public fun invokeOnTimeout (JLjava/lang/Runnable;)Lkotlinx/coroutines/DisposableHandle;
11-
public fun isDispatchNeeded (Lkotlin/coroutines/CoroutineContext;)Z
12-
public fun scheduleResumeAfterDelay (JLkotlinx/coroutines/CancellableContinuation;)V
13-
public fun toString ()Ljava/lang/String;
14-
}
15-
161
public abstract class kotlinx/coroutines/android/HandlerDispatcher : kotlinx/coroutines/MainCoroutineDispatcher, kotlinx/coroutines/Delay {
172
public fun delay (JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
183
public abstract fun getImmediate ()Lkotlinx/coroutines/android/HandlerDispatcher;

binary-compatibility-validator/reference-public-api/kotlinx-coroutines-core.txt

Lines changed: 0 additions & 257 deletions
Large diffs are not rendered by default.

binary-compatibility-validator/reference-public-api/kotlinx-coroutines-javafx.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
public final class kotlinx/coroutines/javafx/JavaFx : kotlinx/coroutines/javafx/JavaFxDispatcher {
2-
public static final field INSTANCE Lkotlinx/coroutines/javafx/JavaFx;
3-
public fun getImmediate ()Lkotlinx/coroutines/MainCoroutineDispatcher;
4-
public fun toString ()Ljava/lang/String;
5-
}
6-
71
public abstract class kotlinx/coroutines/javafx/JavaFxDispatcher : kotlinx/coroutines/MainCoroutineDispatcher, kotlinx/coroutines/Delay {
82
public fun delay (JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
93
public fun dispatch (Lkotlin/coroutines/CoroutineContext;Ljava/lang/Runnable;)V

binary-compatibility-validator/reference-public-api/kotlinx-coroutines-jdk8.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
public final class kotlinx/coroutines/channels8/ChannelsKt {
2-
public static final fun collect (Lkotlinx/coroutines/channels/ReceiveChannel;Ljava/util/stream/Collector;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
3-
}
4-
51
public final class kotlinx/coroutines/future/FutureKt {
62
public static final fun asCompletableFuture (Lkotlinx/coroutines/Deferred;)Ljava/util/concurrent/CompletableFuture;
73
public static final fun asDeferred (Ljava/util/concurrent/CompletionStage;)Lkotlinx/coroutines/Deferred;

binary-compatibility-validator/reference-public-api/kotlinx-coroutines-swing.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
public final class kotlinx/coroutines/swing/Swing : kotlinx/coroutines/swing/SwingDispatcher {
2-
public static final field INSTANCE Lkotlinx/coroutines/swing/Swing;
3-
public fun getImmediate ()Lkotlinx/coroutines/MainCoroutineDispatcher;
4-
public fun toString ()Ljava/lang/String;
5-
}
6-
71
public abstract class kotlinx/coroutines/swing/SwingDispatcher : kotlinx/coroutines/MainCoroutineDispatcher, kotlinx/coroutines/Delay {
82
public fun delay (JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
93
public fun dispatch (Lkotlin/coroutines/CoroutineContext;Ljava/lang/Runnable;)V

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,8 @@ public suspend inline fun <T> suspendAtomicCancellableCoroutine(
181181

182182
/**
183183
* Removes a given node on cancellation.
184-
* @suppress **This is unstable API and it is subject to change.**
185184
*/
186-
@InternalCoroutinesApi
187-
public fun CancellableContinuation<*>.removeOnCancellation(node: LockFreeLinkedListNode) =
185+
internal fun CancellableContinuation<*>.removeOnCancellation(node: LockFreeLinkedListNode) =
188186
invokeOnCancellation(handler = RemoveOnCancel(node).asHandler)
189187

190188
/**

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

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,16 @@ package kotlinx.coroutines
77
import kotlinx.coroutines.internal.*
88
import kotlin.coroutines.*
99

10-
/**
11-
* @suppress **This is unstable API and it is subject to change.**
12-
*/
13-
public fun <T> Result<T>.toState(): Any? =
10+
internal fun <T> Result<T>.toState(): Any? =
1411
if (isSuccess) getOrThrow() else CompletedExceptionally(exceptionOrNull()!!) // todo: need to do it better
1512

1613
/**
1714
* Class for an internal state of a job that was cancelled (completed exceptionally).
1815
*
19-
* **Note: This class cannot be used outside of internal coroutines framework**.
20-
* **Note: cannot be internal and renamed until we get rid of MutableDelegateContinuation in IO**
21-
*
2216
* @param cause the exceptional completion cause. It's either original exceptional cause
2317
* or artificial [CancellationException] if no cause was provided
24-
* @suppress **This is unstable API and it is subject to change.**
2518
*/
26-
@InternalCoroutinesApi
27-
open class CompletedExceptionally(
19+
internal open class CompletedExceptionally(
2820
@JvmField public val cause: Throwable
2921
) {
3022
override fun toString(): String = "$classSimpleName[$cause]"
@@ -33,15 +25,11 @@ open class CompletedExceptionally(
3325
/**
3426
* A specific subclass of [CompletedExceptionally] for cancelled [AbstractContinuation].
3527
*
36-
* **Note: This class cannot be used outside of internal coroutines framework**.
37-
*
3828
* @param continuation the continuation that was cancelled.
3929
* @param cause the exceptional completion cause. If `cause` is null, then a [CancellationException]
4030
* if created on first access to [exception] property.
41-
* @suppress **This is unstable API and it is subject to change.**
4231
*/
43-
@InternalCoroutinesApi
44-
public class CancelledContinuation(
32+
internal class CancelledContinuation(
4533
continuation: Continuation<*>,
4634
cause: Throwable?
4735
) : CompletedExceptionally(cause ?: CancellationException("Continuation $continuation was cancelled normally"))

0 commit comments

Comments
 (0)