launchInCurrentThread

fun <T> launchInCurrentThread(block: suspend CoroutineScope.() -> T): T(source)

Launches a coroutine in the current thread using Dispatchers.Unconfined and blocks until it completes, returning its result. The coroutine will start execution in the current thread and will continue in the same thread until the first suspension point.

Return

The result of the suspending block

Parameters

block

The suspending function to execute in the current thread

Type Parameters

T

The return type of the suspending block

Throws

if the coroutine throws an exception