1 package kotlinx.coroutines.internal 2 3 import kotlinx.coroutines.* 4 5 /** @suppress */ 6 @InternalCoroutinesApi // Emulating DI for Kotlin object's 7 public interface MainDispatcherFactory { 8 public val loadPriority: Int // higher priority wins 9 10 /** 11 * Creates the main dispatcher. [allFactories] parameter contains all factories found by service loader. 12 * This method is not guaranteed to be idempotent. 13 * 14 * It is required that this method fails with an exception instead of returning an instance that doesn't work 15 * correctly as a [Delay]. 16 * The reason for this is that, on the JVM, [DefaultDelay] will use [Dispatchers.Main] for most delays by default 17 * if this method returns an instance without throwing. 18 */ createDispatchernull19 public fun createDispatcher(allFactories: List<MainDispatcherFactory>): MainCoroutineDispatcher 20 21 /** 22 * Hint used along with error message when the factory failed to create a dispatcher. 23 */ 24 public fun hintOnError(): String? = null 25 } 26