open class CoroutineContextProvider {
open val Main: CoroutineContext by lazy { UI }
open val IO: CoroutineContext by lazy { CommonPool }
}
Is the same as :
Copy code
open class CoroutineContextProvider {
open val main: CoroutineContext by lazy { Dispatchers.Main }
open val IO: CoroutineContext by lazy { <http://Dispatchers.IO|Dispatchers.IO> }
}
I was using experimental coroutines and now I have to update them
t
tseisel
10/28/2019, 10:11 PM
Also, you probably won't need those properties to be `lazy`: objects are lazy instantiated and properties of the
Dispatchers
object are not costly to create.
k
Kroppeb
10/28/2019, 10:21 PM
Experimental means there can be breaking changes, and backwards compatibility isn't guaranteed
g
gildor
10/29/2019, 1:07 AM
It's not exactly the same for CommonPool/IO, they have different threading strategies, but yes, for IO use IO dispatcher, it has own thread limits and also shares threads with Default dispatcher
j
Joan Colmenero
10/29/2019, 11:37 AM
So it's the same right? OK I can remove the lazy thing
g
gildor
10/29/2019, 1:05 PM
Not exactly, but anyway, CommonPool is deprecated and IO has better strategy for blocking IO usecase