Should I use doAsync or Coroutines with Room ? Whi...
# android
a
Should I use doAsync or Coroutines with Room ? Which one is better and why ? I have used doAsync with Room that works fine for so far.
g
If you use coroutines in your app, use Coroutines, if you don’t just use doAsync I don’t think that just Room API is real reason to use coroutines, you should understand yourself, do you need coroutines or not, and not only for one API of your app
t
let think about what happen with complex query that takes long time than 5ms
g
huh, you know what, I just now realized that doAsync is not some Room thing, but function from Anko? Isn’t it?
If so, I would use coroutines, because doAsync is just wrapper for thread pool
👍 2
So if it works for you fine, price of creation of new thread is not so high in case of real app, but in general don’t think that I would ever use it
a
But with Coroutines, will it also not create new thread same like created in doAsync ? @gildor I am Novice in Coroutines. Sorry for basic questions.
Thanks for your time and replies
g
It's a bit more complicated question, because with coroutines under the hood Room still uses own thread pool to dispatch requests. Bu in theory room may reuse this thread, or already create it under the hood, but with doAsync you always create new thread.