Skip to content

Remove obsolete CommonPool support #2916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions kotlinx-coroutines-core/common/src/CoroutineContext.common.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import kotlin.coroutines.*
*/
public expect fun CoroutineScope.newCoroutineContext(context: CoroutineContext): CoroutineContext

internal expect fun createDefaultDispatcher(): CoroutineDispatcher

@Suppress("PropertyName")
internal expect val DefaultDelay: Delay

Expand Down
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/js/src/CoroutineContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ private external val navigator: dynamic
private const val UNDEFINED = "undefined"
internal external val process: dynamic

internal actual fun createDefaultDispatcher(): CoroutineDispatcher = when {
internal fun createDefaultDispatcher(): CoroutineDispatcher = when {
// Check if we are running under jsdom. WindowDispatcher doesn't work under jsdom because it accesses MessageEvent#source.
// It is not implemented in jsdom, see https://github.com/jsdom/jsdom/blob/master/Changelog.md
// "It's missing a few semantics, especially around origins, as well as MessageEvent source."
Expand Down
143 changes: 0 additions & 143 deletions kotlinx-coroutines-core/jvm/src/CommonPool.kt

This file was deleted.

13 changes: 0 additions & 13 deletions kotlinx-coroutines-core/jvm/src/CoroutineContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@ import kotlinx.coroutines.scheduling.*
import kotlin.coroutines.*
import kotlin.coroutines.jvm.internal.CoroutineStackFrame

internal const val COROUTINES_SCHEDULER_PROPERTY_NAME = "kotlinx.coroutines.scheduler"

internal val useCoroutinesScheduler = systemProp(COROUTINES_SCHEDULER_PROPERTY_NAME).let { value ->
when (value) {
null, "", "on" -> true
"off" -> false
else -> error("System property '$COROUTINES_SCHEDULER_PROPERTY_NAME' has unrecognized value '$value'")
}
}

internal actual fun createDefaultDispatcher(): CoroutineDispatcher =
if (useCoroutinesScheduler) DefaultScheduler else CommonPool

/**
* Creates context for the new coroutine. It installs [Dispatchers.Default] when no other dispatcher nor
* [ContinuationInterceptor] is specified, and adds optional support for debugging facilities (when turned on).
Expand Down
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/jvm/src/Dispatchers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public actual object Dispatchers {
* Level of parallelism X guarantees that no more than X tasks can be executed in this dispatcher in parallel.
*/
@JvmStatic
public actual val Default: CoroutineDispatcher = createDefaultDispatcher()
public actual val Default: CoroutineDispatcher = DefaultScheduler

/**
* A coroutine dispatcher that is confined to the Main thread operating with UI objects.
Expand Down
56 changes: 0 additions & 56 deletions kotlinx-coroutines-core/jvm/test/CommonPoolTest.kt

This file was deleted.

3 changes: 0 additions & 3 deletions kotlinx-coroutines-core/jvm/test/TestBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,12 @@ public actual open class TestBase(private var disableOutCheck: Boolean) {
}

fun initPoolsBeforeTest() {
CommonPool.usePrivatePool()
DefaultScheduler.usePrivateScheduler()
}

fun shutdownPoolsAfterTest() {
CommonPool.shutdown(SHUTDOWN_TIMEOUT)
DefaultScheduler.shutdown(SHUTDOWN_TIMEOUT)
DefaultExecutor.shutdown(SHUTDOWN_TIMEOUT)
CommonPool.restore()
DefaultScheduler.restore()
}

Expand Down
3 changes: 0 additions & 3 deletions kotlinx-coroutines-core/jvm/test/knit/TestUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ private val OUT_ENABLED = systemProp("guide.tests.sout", false)
fun <R> test(name: String, block: () -> R): List<String> = outputException(name) {
try {
captureOutput(name, stdoutEnabled = OUT_ENABLED) { log ->
CommonPool.usePrivatePool()
DefaultScheduler.usePrivateScheduler()
DefaultExecutor.shutdown(SHUTDOWN_TIMEOUT)
resetCoroutineId()
Expand All @@ -39,15 +38,13 @@ fun <R> test(name: String, block: () -> R): List<String> = outputException(name)
} finally {
// the shutdown
log.println("--- shutting down")
CommonPool.shutdown(SHUTDOWN_TIMEOUT)
DefaultScheduler.shutdown(SHUTDOWN_TIMEOUT)
shutdownDispatcherPools(SHUTDOWN_TIMEOUT)
DefaultExecutor.shutdown(SHUTDOWN_TIMEOUT) // the last man standing -- cleanup all pending tasks
}
checkTestThreads(threadsBefore) // check thread if the main completed successfully
}
} finally {
CommonPool.restore()
DefaultScheduler.restore()
}
}
Expand Down
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/native/src/CoroutineContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal actual object DefaultExecutor : CoroutineDispatcher(), Delay {

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

internal actual fun createDefaultDispatcher(): CoroutineDispatcher =
internal fun createDefaultDispatcher(): CoroutineDispatcher =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be inlined, like on the JVM?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will complicate the maintenance of native-mt branch during rebases

DefaultExecutor

@SharedImmutable
Expand Down