Hello people. Is there any performance advantage a...
# android
s
Hello people. Is there any performance advantage about using retrofit with the suspend modifier to use them in coroutines? It's the version starting at 2.6.0. Which thread will retrofit use in this case? How is this working behind the scenes? Using coroutine thread or some other retrofit thread? The coroutine threads are supposed be "cheaper" and I need to make upto some hundred requests simultaneuously.
j
It uses Call.enqueue which uses OkHttp's thread pool. OkHttp will restrict you to a max of 5 calls in-flight and 60 total at any one time. You can adjust this by creating your own Dispatcher.
👍 1
s
Ok, so it's just a regular thread pool? Yes indeed I'm using a Dispatcher limiting to 25 requests in flight because I'm afraid to unleash all the threads simultaneously. 🙂 Anyway It'll hit the top 60 max right? Have you thought about changing the OkHttp thread pool to coroutines threads? Or is it not possible?..
using suspend modifier in the calls is just a matter of convenience?
so many questions
j
Yes it's convenience. Doing asynchronous I/O all the way through the stack provides few benefits for clients who make so few requests given the complexity it introduces. Maybe someday though.
👍 1
s
Cool. Hope you can do it someday!
Thanks for the help.