2020-02-03 04:22:54 +01:00
|
|
|
package eu.kanade.tachiyomi.util.lang
|
2017-10-13 00:12:29 +02:00
|
|
|
|
2020-02-27 00:12:44 +01:00
|
|
|
import kotlinx.coroutines.CoroutineScope
|
|
|
|
import kotlinx.coroutines.CoroutineStart
|
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
import kotlinx.coroutines.GlobalScope
|
|
|
|
import kotlinx.coroutines.Job
|
|
|
|
import kotlinx.coroutines.launch
|
2017-10-13 00:12:29 +02:00
|
|
|
|
|
|
|
fun launchUI(block: suspend CoroutineScope.() -> Unit): Job =
|
2020-04-25 20:24:45 +02:00
|
|
|
GlobalScope.launch(Dispatchers.Main, CoroutineStart.DEFAULT, block)
|
2017-10-13 00:12:29 +02:00
|
|
|
|
2020-02-04 01:11:18 +01:00
|
|
|
fun launchIO(block: suspend CoroutineScope.() -> Unit): Job =
|
2020-04-25 20:24:45 +02:00
|
|
|
GlobalScope.launch(Dispatchers.IO, CoroutineStart.DEFAULT, block)
|
2020-02-04 01:11:18 +01:00
|
|
|
|
2017-10-13 00:12:29 +02:00
|
|
|
fun launchNow(block: suspend CoroutineScope.() -> Unit): Job =
|
2020-04-25 20:24:45 +02:00
|
|
|
GlobalScope.launch(Dispatchers.Main, CoroutineStart.UNDISPATCHED, block)
|