Exerosis
05/15/2023, 11:42 PMinterface Scheduler {
fun isMainThread(): Boolean
fun runTask(task: () -> (Unit))
fun runTaskIn(duration: Duration, task: () -> (Unit))
}
Given a really simple scheduler like this that runs on a single main thread. Could someone show me how to create a Dispatcher with Delay and a function:
fun <Return> blocking(block: suspend () -> (Return)): Return
That can be used to block any thread (including the main one) until a coroutine completes. Similar to runBlocking (if the runBlocking internals can somehow be used that would be great but I couldn't see a way)ephemient
05/15/2023, 11:48 PMuli
05/17/2023, 7:12 AMrunTask*
with suspendCoroutine
and then call it within runBlocking
?