coder82
10/29/2020, 1:12 PMcoder82
10/29/2020, 1:13 PMcoder82
10/29/2020, 1:13 PMoverride val coroutineContext:CoroutineContext
get() = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
coder82
10/29/2020, 1:13 PMcoder82
10/29/2020, 1:13 PMcoder82
10/29/2020, 1:14 PMoverride fun invokeLater(vararg params:Any, block:suspend AdapterProcess.() -> Unit):Job {
currentJob = launch(coroutineContext) {
this@DummyProcess.block()
}
return currentJob
}
coder82
10/29/2020, 1:14 PMmateusz.kwiecinski
10/29/2020, 1:21 PMcoroutineContext
field you invoke getter get()
hence you create new singleThreadExecutor on each invocation.
override val coroutineContext:CoroutineContext = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
☝️ this would assign created dispatcher to a field once and read its value latercoder82
10/29/2020, 1:24 PMcoder82
10/29/2020, 1:24 PMcoder82
10/29/2020, 1:24 PM