diff --git a/kotlinx-coroutines-core/concurrent/src/Builders.concurrent.kt b/kotlinx-coroutines-core/concurrent/src/Builders.concurrent.kt index 7c0581b9d9..b6b74b3f12 100644 --- a/kotlinx-coroutines-core/concurrent/src/Builders.concurrent.kt +++ b/kotlinx-coroutines-core/concurrent/src/Builders.concurrent.kt @@ -22,3 +22,18 @@ import kotlin.coroutines.* * block, potentially leading to thread starvation issues. */ public expect fun runBlocking(context: CoroutineContext = EmptyCoroutineContext, block: suspend CoroutineScope.() -> T): T + +/** + * Runs the given coroutine on the current thread, blocking until completion. + * + * This is like [runBlocking], but returns [Unit] which is a useful utility to run coroutines for their side effect + * when [Unit] is expected. + * + * Example: + * ```kt + * fun foobar() = runBlocking { ... } + * ``` + */ +public fun doBlocking(context: CoroutineContext = EmptyCoroutineContext, block: suspend CoroutineScope.() -> Unit) { + runBlocking(context, block) +}