Skip to content

Commit 81d7780

Browse files
authored
Remove obsolete CommonPool support (#2916)
* We state that it's deprecated since the initial release of CoroutineScheduler * It is an additional DEX load for Android
1 parent 7523368 commit 81d7780

File tree

9 files changed

+3
-223
lines changed

9 files changed

+3
-223
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import kotlin.coroutines.*
1212
*/
1313
public expect fun CoroutineScope.newCoroutineContext(context: CoroutineContext): CoroutineContext
1414

15-
internal expect fun createDefaultDispatcher(): CoroutineDispatcher
16-
1715
@Suppress("PropertyName")
1816
internal expect val DefaultDelay: Delay
1917

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ private external val navigator: dynamic
1212
private const val UNDEFINED = "undefined"
1313
internal external val process: dynamic
1414

15-
internal actual fun createDefaultDispatcher(): CoroutineDispatcher = when {
15+
internal fun createDefaultDispatcher(): CoroutineDispatcher = when {
1616
// Check if we are running under jsdom. WindowDispatcher doesn't work under jsdom because it accesses MessageEvent#source.
1717
// It is not implemented in jsdom, see https://github.com/jsdom/jsdom/blob/master/Changelog.md
1818
// "It's missing a few semantics, especially around origins, as well as MessageEvent source."

kotlinx-coroutines-core/jvm/src/CommonPool.kt

Lines changed: 0 additions & 143 deletions
This file was deleted.

kotlinx-coroutines-core/jvm/src/CoroutineContext.kt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,6 @@ import kotlinx.coroutines.scheduling.*
99
import kotlin.coroutines.*
1010
import kotlin.coroutines.jvm.internal.CoroutineStackFrame
1111

12-
internal const val COROUTINES_SCHEDULER_PROPERTY_NAME = "kotlinx.coroutines.scheduler"
13-
14-
internal val useCoroutinesScheduler = systemProp(COROUTINES_SCHEDULER_PROPERTY_NAME).let { value ->
15-
when (value) {
16-
null, "", "on" -> true
17-
"off" -> false
18-
else -> error("System property '$COROUTINES_SCHEDULER_PROPERTY_NAME' has unrecognized value '$value'")
19-
}
20-
}
21-
22-
internal actual fun createDefaultDispatcher(): CoroutineDispatcher =
23-
if (useCoroutinesScheduler) DefaultScheduler else CommonPool
24-
2512
/**
2613
* Creates context for the new coroutine. It installs [Dispatchers.Default] when no other dispatcher nor
2714
* [ContinuationInterceptor] is specified, and adds optional support for debugging facilities (when turned on).

kotlinx-coroutines-core/jvm/src/Dispatchers.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public actual object Dispatchers {
2929
* Level of parallelism X guarantees that no more than X tasks can be executed in this dispatcher in parallel.
3030
*/
3131
@JvmStatic
32-
public actual val Default: CoroutineDispatcher = createDefaultDispatcher()
32+
public actual val Default: CoroutineDispatcher = DefaultScheduler
3333

3434
/**
3535
* A coroutine dispatcher that is confined to the Main thread operating with UI objects.

kotlinx-coroutines-core/jvm/test/CommonPoolTest.kt

Lines changed: 0 additions & 56 deletions
This file was deleted.

kotlinx-coroutines-core/jvm/test/TestBase.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,12 @@ public actual open class TestBase(private var disableOutCheck: Boolean) {
199199
}
200200

201201
fun initPoolsBeforeTest() {
202-
CommonPool.usePrivatePool()
203202
DefaultScheduler.usePrivateScheduler()
204203
}
205204

206205
fun shutdownPoolsAfterTest() {
207-
CommonPool.shutdown(SHUTDOWN_TIMEOUT)
208206
DefaultScheduler.shutdown(SHUTDOWN_TIMEOUT)
209207
DefaultExecutor.shutdown(SHUTDOWN_TIMEOUT)
210-
CommonPool.restore()
211208
DefaultScheduler.restore()
212209
}
213210

kotlinx-coroutines-core/jvm/test/knit/TestUtil.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ private val OUT_ENABLED = systemProp("guide.tests.sout", false)
2626
fun <R> test(name: String, block: () -> R): List<String> = outputException(name) {
2727
try {
2828
captureOutput(name, stdoutEnabled = OUT_ENABLED) { log ->
29-
CommonPool.usePrivatePool()
3029
DefaultScheduler.usePrivateScheduler()
3130
DefaultExecutor.shutdown(SHUTDOWN_TIMEOUT)
3231
resetCoroutineId()
@@ -39,15 +38,13 @@ fun <R> test(name: String, block: () -> R): List<String> = outputException(name)
3938
} finally {
4039
// the shutdown
4140
log.println("--- shutting down")
42-
CommonPool.shutdown(SHUTDOWN_TIMEOUT)
4341
DefaultScheduler.shutdown(SHUTDOWN_TIMEOUT)
4442
shutdownDispatcherPools(SHUTDOWN_TIMEOUT)
4543
DefaultExecutor.shutdown(SHUTDOWN_TIMEOUT) // the last man standing -- cleanup all pending tasks
4644
}
4745
checkTestThreads(threadsBefore) // check thread if the main completed successfully
4846
}
4947
} finally {
50-
CommonPool.restore()
5148
DefaultScheduler.restore()
5249
}
5350
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal actual object DefaultExecutor : CoroutineDispatcher(), Delay {
2525

2626
internal fun loopWasShutDown(): Nothing = error("Cannot execute task because event loop was shut down")
2727

28-
internal actual fun createDefaultDispatcher(): CoroutineDispatcher =
28+
internal fun createDefaultDispatcher(): CoroutineDispatcher =
2929
DefaultExecutor
3030

3131
@SharedImmutable

0 commit comments

Comments
 (0)