@@ -11,18 +11,27 @@ internal actual val DefaultDelay: Delay = initializeDefaultDelay()
11
11
12
12
private fun initializeDefaultDelay (): Delay {
13
13
// Opt-out flag
14
- if (! defaultMainDelayOptIn) return DefaultExecutor
14
+ if (! defaultMainDelayOptIn) return DefaultDelayImpl
15
15
val main = Dispatchers .Main
16
16
/*
17
17
* When we already are working with UI and Main threads, it makes
18
18
* no sense to create a separate thread with timer that cannot be controller
19
19
* by the UI runtime.
20
20
*/
21
- return if (main.isMissing() || main !is Delay ) DefaultExecutor else main
21
+ return if (main.isMissing() || main !is Delay ) DefaultDelayImpl else main
22
22
}
23
23
24
- @Suppress(" PLATFORM_CLASS_MAPPED_TO_KOTLIN" )
25
- internal actual object DefaultExecutor : EventLoopImplBase(), Runnable {
24
+ internal object DefaultExecutor {
25
+ fun shutdown () = DefaultDelayImpl .shutdown()
26
+
27
+ fun ensureStarted () = DefaultDelayImpl .ensureStarted()
28
+
29
+ fun shutdownForTests (timeout : Long ) = DefaultDelayImpl .shutdownForTests(timeout)
30
+
31
+ val isThreadPresent: Boolean get() = DefaultDelayImpl .isThreadPresent
32
+ }
33
+
34
+ private object DefaultDelayImpl : EventLoopImplBase(), Runnable {
26
35
const val THREAD_NAME = " kotlinx.coroutines.DefaultExecutor"
27
36
28
37
init {
@@ -61,7 +70,7 @@ internal actual object DefaultExecutor : EventLoopImplBase(), Runnable {
61
70
return debugStatus == SHUTDOWN_REQ || debugStatus == SHUTDOWN_ACK
62
71
}
63
72
64
- actual override fun enqueue (task : Runnable ) {
73
+ override fun enqueue (task : Runnable ) {
65
74
if (isShutDown) shutdownError()
66
75
super .enqueue(task)
67
76
}
@@ -137,7 +146,7 @@ internal actual object DefaultExecutor : EventLoopImplBase(), Runnable {
137
146
* the singleton itself instead of using parent' thread one
138
147
* in order not to accidentally capture temporary application classloader.
139
148
*/
140
- contextClassLoader = this @DefaultExecutor .javaClass.classLoader
149
+ contextClassLoader = this @DefaultDelayImpl .javaClass.classLoader
141
150
isDaemon = true
142
151
start()
143
152
}
0 commit comments