Closed
Description
I have to use an API that accepts an Executor
as a parameter. How can I create an Executor
that is backed by Dispatchers.Default
?
Can a CoroutineDispatcher.asExecutor(): Executor
function be added to support this use case?
fun externalApi(executor: Executor)
fun example() {
val executor: Executor = Dispatchers.Default.asExecutor()
externalApi(executor)
}
Even better would be a fun CoroutineContext.asExecutor(): Executor
function. I would imagine if the receiver CoroutineContext
does not have a ContinuationInterceptor
, this function would throw.