1 package kotlinx.coroutines.internal 2 3 import kotlinx.coroutines.* 4 import kotlinx.coroutines.DefaultDelay 5 import kotlin.coroutines.* 6 7 /** 8 * Wrapping dispatcher that has a nice user-supplied `toString()` representation 9 */ 10 internal class NamedDispatcher( 11 private val dispatcher: CoroutineDispatcher, 12 private val name: String <lambda>null13) : CoroutineDispatcher(), Delay by (dispatcher as? Delay ?: DefaultDelay) { 14 15 override fun isDispatchNeeded(context: CoroutineContext): Boolean = dispatcher.isDispatchNeeded(context) 16 17 override fun dispatch(context: CoroutineContext, block: Runnable) = dispatcher.dispatch(context, block) 18 19 @InternalCoroutinesApi 20 override fun dispatchYield(context: CoroutineContext, block: Runnable) = dispatcher.dispatchYield(context, block) 21 22 override fun toString(): String { 23 return name 24 } 25 }