ExecutorCoroutineDispatcher

abstract class ExecutorCoroutineDispatcher : 
    CoroutineDispatcher,
    Closeable
(source)

Platform and version requirements: JVM

CoroutineDispatcher that has underlying Executor for dispatching tasks. Instances of ExecutorCoroutineDispatcher should be closed by the owner of the dispatcher.

This class is generally used as a bridge between coroutine-based API and asynchronous API that requires an instance of the Executor.

Constructors

<init>

ExecutorCoroutineDispatcher()

CoroutineDispatcher that has underlying Executor for dispatching tasks. Instances of ExecutorCoroutineDispatcher should be closed by the owner of the dispatcher.

Properties

executor

abstract val executor: Executor

Underlying executor of current CoroutineDispatcher.

Functions

close

abstract fun close(): Unit

Closes this coroutine dispatcher and shuts down its executor.

Inherited Functions

interceptContinuation

fun <T> interceptContinuation(
    continuation: Continuation<T>
): Continuation<T>

Returns a continuation that wraps the provided continuation, thus intercepting all resumptions.

isDispatchNeeded

open fun isDispatchNeeded(context: CoroutineContext): Boolean

Returns true if the execution of the coroutine should be performed with dispatch method. The default behavior for most dispatchers is to return true.

releaseInterceptedContinuation

open fun releaseInterceptedContinuation(
    continuation: Continuation<*>
): Unit

Extension Functions

asExecutor

fun CoroutineDispatcher.asExecutor(): Executor

Converts an instance of CoroutineDispatcher to an implementation of Executor.