Skip to content

Commit fd982ae

Browse files
committed
Review fixup: signature changed, docs fixed
1 parent 4420c79 commit fd982ae

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public final class kotlinx/coroutines/Dispatchers {
277277
public static final fun getIO ()Lkotlinx/coroutines/CoroutineDispatcher;
278278
public static final fun getMain ()Lkotlinx/coroutines/MainCoroutineDispatcher;
279279
public static final fun getUnconfined ()Lkotlinx/coroutines/CoroutineDispatcher;
280-
public final fun shutdown (Lkotlinx/coroutines/CoroutineDispatcher;)V
280+
public final fun shutdownDefaultDispatcher (Lkotlinx/coroutines/Dispatchers;)V
281281
}
282282

283283
public final class kotlinx/coroutines/DispatchersKt {

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

+11-3
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,20 @@ public expect object Dispatchers {
8080
public val Unconfined: CoroutineDispatcher
8181

8282
/**
83-
* Shuts down the dispatcher.
83+
* Shuts down the [Default] dispatcher.
8484
*
8585
* Its implementation depends on the platform:
8686
* - On Kotlin/JVM and Kotlin/JS takes no effect.
87-
* - On Kotlin/Native requests termination of the worker created by the [Default] dispatcher.
87+
* - On Kotlin/Native requests termination of the Worker created by the [Default] dispatcher.
88+
* [Default] dispatcher is backed by a [SingleThreadDispatcher] that creates a Worker and never shuts it down.
89+
* According to the current implementation, Kotlin/Native memory leak checker can not do it’s job while
90+
* there are active workers left at the program shutdown. Thus, if the memory leak checker is activated
91+
* (`Platform.isMemoryLeakCheckerActive = true`) this method should be called before program termination
92+
* to avoid the leaking worker.
93+
*
94+
* **Note**: For now this declaration is only present in `native-mt` versions of `kotlinx.coroutines`.
95+
* It will be available in regular versions when #2558 is implemeted.
8896
*/
8997
@ExperimentalCoroutinesApi
90-
public fun CoroutineDispatcher.shutdown()
98+
public fun Dispatchers.shutdownDefaultDispatcher()
9199
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public actual object Dispatchers {
1010
public actual val Default: CoroutineDispatcher = createDefaultDispatcher()
1111
public actual val Main: MainCoroutineDispatcher = JsMainDispatcher(Default, false)
1212
public actual val Unconfined: CoroutineDispatcher = kotlinx.coroutines.Unconfined
13-
public actual fun CoroutineDispatcher.shutdown() {}
13+
public actual fun Dispatchers.shutdownDefaultDispatcher() {}
1414
}
1515

1616
private class JsMainDispatcher(

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,5 @@ public actual object Dispatchers {
116116
@JvmStatic
117117
public val IO: CoroutineDispatcher = DefaultScheduler.IO
118118

119-
public actual fun CoroutineDispatcher.shutdown() {}
119+
public actual fun Dispatchers.shutdownDefaultDispatcher() {}
120120
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public actual object Dispatchers {
1313
public actual val Main: MainCoroutineDispatcher = createMainDispatcher(Default)
1414
public actual val Unconfined: CoroutineDispatcher get() = kotlinx.coroutines.Unconfined // Avoid freezing
1515

16-
public actual fun CoroutineDispatcher.shutdown() {
17-
if (this === DefaultDispatcher) shutdown()
16+
public actual fun Dispatchers.shutdownDefaultDispatcher() {
17+
DefaultDispatcher.shutdown()
1818
}
1919
}
2020

0 commit comments

Comments
 (0)