diff --git a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/internal/runBlocking.kt b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/internal/runBlocking.kt new file mode 100644 index 000000000..c080aaeb3 --- /dev/null +++ b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/internal/runBlocking.kt @@ -0,0 +1,12 @@ +package net.mamoe.mirai.utils.internal + +import kotlinx.coroutines.CoroutineScope +import kotlin.coroutines.CoroutineContext + +/** + * Mirror of `runBlocking` from `kotlinx.serialization` on JVM + */ +internal actual fun runBlocking( + context: CoroutineContext, + block: suspend CoroutineScope.() -> T +): T = kotlinx.coroutines.runBlocking(context, block) \ No newline at end of file diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/internal/runBlocking.common.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/internal/runBlocking.common.kt new file mode 100644 index 000000000..098c63580 --- /dev/null +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/internal/runBlocking.common.kt @@ -0,0 +1,22 @@ +/* + * Copyright 2020 Mamoe Technologies and contributors. + * + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. + * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. + * + * https://github.com/mamoe/mirai/blob/master/LICENSE + */ + +package net.mamoe.mirai.utils.internal + +import kotlinx.coroutines.CoroutineScope +import kotlin.coroutines.CoroutineContext +import kotlin.coroutines.EmptyCoroutineContext + +/** + * Mirror of `runBlocking` from `kotlinx.serialization` on JVM. + */ +internal expect fun runBlocking( + context: CoroutineContext = EmptyCoroutineContext, + block: suspend CoroutineScope.() -> T +): T \ No newline at end of file diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/internal/runBlocking.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/internal/runBlocking.kt new file mode 100644 index 000000000..bea73b9af --- /dev/null +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/internal/runBlocking.kt @@ -0,0 +1,12 @@ +package net.mamoe.mirai.utils.internal + +import kotlinx.coroutines.CoroutineScope +import kotlin.coroutines.CoroutineContext + +/** + * Mirror of `runBlocking` from `kotlinx.serialization` on JVM. + */ +internal actual fun runBlocking( + context: CoroutineContext, + block: suspend CoroutineScope.() -> T +): T = kotlinx.coroutines.runBlocking(context, block) \ No newline at end of file