commonMain.internal.NamedDispatcher.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlinx-coroutines-core-jvm Show documentation
Show all versions of kotlinx-coroutines-core-jvm Show documentation
Coroutines support libraries for Kotlin
The newest version!
package kotlinx.coroutines.internal
import kotlinx.coroutines.*
import kotlinx.coroutines.DefaultDelay
import kotlin.coroutines.*
/**
* Wrapping dispatcher that has a nice user-supplied `toString()` representation
*/
internal class NamedDispatcher(
private val dispatcher: CoroutineDispatcher,
private val name: String
) : CoroutineDispatcher(), Delay by (dispatcher as? Delay ?: DefaultDelay) {
override fun isDispatchNeeded(context: CoroutineContext): Boolean = dispatcher.isDispatchNeeded(context)
override fun dispatch(context: CoroutineContext, block: Runnable) = dispatcher.dispatch(context, block)
@InternalCoroutinesApi
override fun dispatchYield(context: CoroutineContext, block: Runnable) = dispatcher.dispatchYield(context, block)
override fun toString(): String {
return name
}
}