File tree 4 files changed +14
-2
lines changed
4 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -78,4 +78,14 @@ public expect object Dispatchers {
78
78
* the value of [CoroutineStart.UNDISPATCHED].
79
79
*/
80
80
public val Unconfined : CoroutineDispatcher
81
+
82
+ /* *
83
+ * Shuts down the dispatcher.
84
+ *
85
+ * Its implementation depends on the platform:
86
+ * - On Kotlin/JVM and Kotlin/JS takes no effect.
87
+ * - On Kotlin/Native requests termination of the worker created by the [Default] dispatcher.
88
+ */
89
+ @ExperimentalCoroutinesApi
90
+ public fun CoroutineDispatcher.shutdown ()
81
91
}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ public actual object Dispatchers {
10
10
public actual val Default : CoroutineDispatcher = createDefaultDispatcher()
11
11
public actual val Main : MainCoroutineDispatcher = JsMainDispatcher (Default , false )
12
12
public actual val Unconfined : CoroutineDispatcher = kotlinx.coroutines.Unconfined
13
+ public actual fun CoroutineDispatcher.shutdown () {}
13
14
}
14
15
15
16
private class JsMainDispatcher (
Original file line number Diff line number Diff line change @@ -115,4 +115,6 @@ public actual object Dispatchers {
115
115
*/
116
116
@JvmStatic
117
117
public val IO : CoroutineDispatcher = DefaultScheduler .IO
118
+
119
+ public actual fun CoroutineDispatcher.shutdown () {}
118
120
}
Original file line number Diff line number Diff line change @@ -13,8 +13,7 @@ public actual object Dispatchers {
13
13
public actual val Main : MainCoroutineDispatcher = createMainDispatcher(Default )
14
14
public actual val Unconfined : CoroutineDispatcher get() = kotlinx.coroutines.Unconfined // Avoid freezing
15
15
16
- @ExperimentalCoroutinesApi
17
- public fun CoroutineDispatcher.shutdown () {
16
+ public actual fun CoroutineDispatcher.shutdown () {
18
17
if (this == = DefaultDispatcher ) shutdown()
19
18
}
20
19
}
You can’t perform that action at this time.
0 commit comments