asCoroutineDispatcher

Represents an arbitrary Handler as an implementation of CoroutineDispatcher with an optional name for nicer debugging

Rejected execution

If the underlying handler is closed and its message-scheduling methods start to return false on an attempt to submit a continuation task to the resulting dispatcher, then the Job of the affected task is cancelled and the task is submitted to the Dispatchers.IO, so that the affected coroutine can cleanup its resources and promptly complete.