Skip to content

Commit 6a33516

Browse files
committed
Fixes
1 parent f087205 commit 6a33516

File tree

6 files changed

+41
-55
lines changed

6 files changed

+41
-55
lines changed

kotlinx-coroutines-core/api/kotlinx-coroutines-core.api

+9
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,15 @@ public final class kotlinx/coroutines/TimeoutKt {
545545
public static final fun withTimeoutOrNull-KLykuaI (JLkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
546546
}
547547

548+
public final class kotlinx/coroutines/YieldContext : kotlin/coroutines/AbstractCoroutineContextElement {
549+
public static final field Key Lkotlinx/coroutines/YieldContext$Key;
550+
public field dispatcherWasUnconfined Z
551+
public fun <init> ()V
552+
}
553+
554+
public final class kotlinx/coroutines/YieldContext$Key : kotlin/coroutines/CoroutineContext$Key {
555+
}
556+
548557
public final class kotlinx/coroutines/YieldKt {
549558
public static final fun yield (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
550559
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ internal object Unconfined : CoroutineDispatcher() {
3838
/**
3939
* Used to detect calls to [Unconfined.dispatch] from [yield] function.
4040
*/
41+
@PublishedApi
4142
internal class YieldContext : AbstractCoroutineContextElement(Key) {
4243
companion object Key : CoroutineContext.Key<YieldContext>
4344

kotlinx-coroutines-test/api/kotlinx-coroutines-test.api

+7-20
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@ public abstract interface class kotlinx/coroutines/test/DelayController {
99
public abstract fun runCurrent ()V
1010
}
1111

12-
public final class kotlinx/coroutines/test/StandardTestDispatcher : kotlinx/coroutines/test/TestDispatcher, kotlinx/coroutines/Delay {
13-
public fun <init> ()V
14-
public fun <init> (Lkotlinx/coroutines/test/TestCoroutineScheduler;Ljava/lang/String;)V
15-
public synthetic fun <init> (Lkotlinx/coroutines/test/TestCoroutineScheduler;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
16-
public fun dispatch (Lkotlin/coroutines/CoroutineContext;Ljava/lang/Runnable;)V
17-
public fun getScheduler ()Lkotlinx/coroutines/test/TestCoroutineScheduler;
18-
public fun toString ()Ljava/lang/String;
19-
}
20-
2112
public final class kotlinx/coroutines/test/TestBuildersKt {
2213
public static final fun runBlockingTest (Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function2;)V
2314
public static final fun runBlockingTest (Lkotlinx/coroutines/test/TestCoroutineDispatcher;Lkotlin/jvm/functions/Function2;)V
@@ -49,6 +40,13 @@ public final class kotlinx/coroutines/test/TestCoroutineDispatcher : kotlinx/cor
4940
public fun toString ()Ljava/lang/String;
5041
}
5142

43+
public final class kotlinx/coroutines/test/TestCoroutineDispatchersKt {
44+
public static final fun StandardTestDispatcher (Lkotlinx/coroutines/test/TestCoroutineScheduler;Ljava/lang/String;)Lkotlinx/coroutines/test/TestDispatcher;
45+
public static synthetic fun StandardTestDispatcher$default (Lkotlinx/coroutines/test/TestCoroutineScheduler;Ljava/lang/String;ILjava/lang/Object;)Lkotlinx/coroutines/test/TestDispatcher;
46+
public static final fun UnconfinedTestDispatcher (Lkotlinx/coroutines/test/TestCoroutineScheduler;Ljava/lang/String;)Lkotlinx/coroutines/test/TestDispatcher;
47+
public static synthetic fun UnconfinedTestDispatcher$default (Lkotlinx/coroutines/test/TestCoroutineScheduler;Ljava/lang/String;ILjava/lang/Object;)Lkotlinx/coroutines/test/TestDispatcher;
48+
}
49+
5250
public final class kotlinx/coroutines/test/TestCoroutineExceptionHandler : kotlin/coroutines/AbstractCoroutineContextElement, kotlinx/coroutines/CoroutineExceptionHandler, kotlinx/coroutines/test/UncaughtExceptionCaptor {
5351
public fun <init> ()V
5452
public fun cleanupTestCoroutinesCaptor ()V
@@ -88,7 +86,6 @@ public final class kotlinx/coroutines/test/TestCoroutineScopeKt {
8886
}
8987

9088
public abstract class kotlinx/coroutines/test/TestDispatcher : kotlinx/coroutines/CoroutineDispatcher, kotlinx/coroutines/Delay {
91-
public fun <init> ()V
9289
public fun delay (JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
9390
public abstract fun getScheduler ()Lkotlinx/coroutines/test/TestCoroutineScheduler;
9491
public fun invokeOnTimeout (JLjava/lang/Runnable;Lkotlin/coroutines/CoroutineContext;)Lkotlinx/coroutines/DisposableHandle;
@@ -105,13 +102,3 @@ public abstract interface class kotlinx/coroutines/test/UncaughtExceptionCaptor
105102
public abstract fun getUncaughtExceptions ()Ljava/util/List;
106103
}
107104

108-
public final class kotlinx/coroutines/test/UnconfinedTestDispatcher : kotlinx/coroutines/test/TestDispatcher, kotlinx/coroutines/Delay {
109-
public fun <init> ()V
110-
public fun <init> (Lkotlinx/coroutines/test/TestCoroutineScheduler;Ljava/lang/String;)V
111-
public synthetic fun <init> (Lkotlinx/coroutines/test/TestCoroutineScheduler;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
112-
public fun dispatch (Lkotlin/coroutines/CoroutineContext;Ljava/lang/Runnable;)V
113-
public fun getScheduler ()Lkotlinx/coroutines/test/TestCoroutineScheduler;
114-
public fun isDispatchNeeded (Lkotlin/coroutines/CoroutineContext;)Z
115-
public fun toString ()Ljava/lang/String;
116-
}
117-

kotlinx-coroutines-test/common/src/TestCoroutineDispatcher.kt

-6
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ public class TestCoroutineDispatcher(public override val scheduler: TestCoroutin
3636
}
3737
}
3838

39-
/** @suppress */
40-
override fun processEvent(time: Long, marker: Any) {
41-
check(marker is Runnable)
42-
marker.run()
43-
}
44-
4539
/** @suppress */
4640
override fun dispatch(context: CoroutineContext, block: Runnable) {
4741
checkSchedulerInContext(scheduler, context)

kotlinx-coroutines-test/common/src/TestCoroutineDispatchers.kt

+19-27
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,19 @@ import kotlin.coroutines.*
2929
* scheduler in order for the tasks to run.
3030
*/
3131
@ExperimentalCoroutinesApi
32-
public class UnconfinedTestDispatcher(
33-
public override val scheduler: TestCoroutineScheduler = TestCoroutineScheduler(),
34-
private val name: String? = null
35-
): TestDispatcher(), Delay {
32+
@Suppress("FunctionName")
33+
public fun UnconfinedTestDispatcher(
34+
scheduler: TestCoroutineScheduler = TestCoroutineScheduler(),
35+
name: String? = null
36+
): TestDispatcher = UnconfinedTestDispatcherImpl(scheduler, name)
3637

37-
/** @suppress */
38-
override fun processEvent(time: Long, marker: Any) {
39-
check(marker is Runnable)
40-
marker.run()
41-
}
38+
private class UnconfinedTestDispatcherImpl(
39+
override val scheduler: TestCoroutineScheduler,
40+
private val name: String? = null
41+
): TestDispatcher() {
4242

43-
/** @suppress */
4443
override fun isDispatchNeeded(context: CoroutineContext): Boolean = false
4544

46-
/** @suppress */
4745
@Suppress("INVISIBLE_MEMBER")
4846
override fun dispatch(context: CoroutineContext, block: Runnable) {
4947
checkSchedulerInContext(scheduler, context)
@@ -64,9 +62,7 @@ public class UnconfinedTestDispatcher(
6462
)
6563
}
6664

67-
/** @suppress */
6865
override fun toString(): String = "${name ?: "UnconfinedTestDispatcher"}[scheduler=$scheduler]"
69-
7066
}
7167

7268
/**
@@ -88,26 +84,22 @@ public class UnconfinedTestDispatcher(
8884
*
8985
* @see UnconfinedTestDispatcher for a dispatcher that is not confined to any particular thread.
9086
*/
87+
@Suppress("FunctionName")
88+
public fun StandardTestDispatcher(
89+
scheduler: TestCoroutineScheduler = TestCoroutineScheduler(),
90+
name: String? = null
91+
): TestDispatcher = StandardTestDispatcherImpl(scheduler, name)
92+
9193
@ExperimentalCoroutinesApi
92-
public class StandardTestDispatcher(
93-
public override val scheduler: TestCoroutineScheduler = TestCoroutineScheduler(),
94+
private class StandardTestDispatcherImpl(
95+
override val scheduler: TestCoroutineScheduler = TestCoroutineScheduler(),
9496
private val name: String? = null
95-
): TestDispatcher(), Delay {
97+
): TestDispatcher() {
9698

97-
/** @suppress */
98-
override fun processEvent(time: Long, marker: Any) {
99-
check(marker is Runnable)
100-
marker.run()
101-
}
102-
103-
/** @suppress */
104-
@Suppress("INVISIBLE_MEMBER")
10599
override fun dispatch(context: CoroutineContext, block: Runnable) {
106100
checkSchedulerInContext(scheduler, context)
107101
scheduler.registerEvent(this, 0, block) { false }
108102
}
109103

110-
/** @suppress */
111-
override fun toString(): String = "${name ?: "ConfinedTestDispatcher"}[scheduler=$scheduler]"
112-
104+
override fun toString(): String = "${name ?: "StandardTestDispatcher"}[scheduler=$scheduler]"
113105
}

kotlinx-coroutines-test/common/src/TestDispatcher.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ import kotlin.jvm.*
1212
* A test dispatcher that can interface with a [TestCoroutineScheduler].
1313
*/
1414
@ExperimentalCoroutinesApi
15-
public abstract class TestDispatcher: CoroutineDispatcher(), Delay {
15+
public sealed class TestDispatcher: CoroutineDispatcher(), Delay {
1616
/** The scheduler that this dispatcher is linked to. */
1717
@ExperimentalCoroutinesApi
1818
public abstract val scheduler: TestCoroutineScheduler
1919

2020
/** Notifies the dispatcher that it should process a single event marked with [marker] happening at time [time]. */
21-
internal abstract fun processEvent(time: Long, marker: Any)
21+
internal open fun processEvent(time: Long, marker: Any) {
22+
check(marker is Runnable)
23+
marker.run()
24+
}
2225

2326
/** @suppress */
2427
override fun scheduleResumeAfterDelay(timeMillis: Long, continuation: CancellableContinuation<Unit>) {

0 commit comments

Comments
 (0)