I’ve got what I believe is latest best-practice:
class BasicBot : CoroutineScope, AutoCloseable, Runnable {
@Transient
private val job = Job()
override val coroutineContext: CoroutineContext
get() = job + Dispatchers.Default
override fun run() {
launch(Dispatchers.Default) {
Is that launch(Dispatchers.Default)
redundant with the previously declared coroutineContext that uses Default? Hard to tell from the docs what influences nested defaults where. Thank you!
My overall goal is to “Launch stuff on the Default dispatcher so it uses reasonable parallelism, and don’t leave any running when the AutoClosable closes.”