hands-on icon indicating copy to clipboard operation
hands-on copied to clipboard

Introduction to Coroutines and Channels: Using Suspend Functions Inaccuracy

Open doridori opened this issue 4 years ago • 0 comments
trafficstars

Hey,

Reading https://play.kotlinlang.org/hands-on/Introduction%20to%20Coroutines%20and%20Channels/04_Suspend I have noticed an inaccuracy.

We have the below:

Screenshot 2021-09-10 at 13 48 44

This description is misleading, as the requests are not actually "taking place" | "being sent" on the UI thread at all. The requests are being initiated from and responses processed by the main thread but retrofit under the hood is enqueing them, which will result in them actually being run on a worker Thread. The log in the screenshot is logging the thead the response is processed on after the worker thread has finished.

It sounds pendantic but as this is a course on concurrency at present it's a little misleading. I can submit a PR to re-word this if desired.

Here is a call to the internal enqueue for reference https://github.com/square/retrofit/blob/master/retrofit/src/main/java/retrofit2/KotlinExtensions.kt#L36

doridori avatar Sep 10 '21 12:09 doridori