rocketraman
02/05/2025, 2:24 PM<http://Dispatchers.IO|Dispatchers.IO>
-- here is . This seems wrong -- IO is of course designed for blocking I/O, but the ktor call may or may not be blocking depending on the underlying engine. Ktor presumably internally uses the appropriate dispatcher based on whether the actual engine in use is blocking or not. Calling code is therefore free to use a dispatcher based on its own requirements e.g. limiting the number of concurrent requests or whatever, rather than coupling the choice of dispatcher to the engine configuration.
If this is right, some official guidance around this would be welcome here and in the docs.Aleksei Tirman [JB]
02/06/2025, 10:55 AMrocketraman
02/06/2025, 2:50 PMAleksei Tirman [JB]
02/06/2025, 3:01 PMTodd
02/10/2025, 3:04 PMrocketraman
02/10/2025, 3:29 PMNSOperationQueue
. So even here, wrapping the ktor call in <http://Dispatchers.IO|Dispatchers.IO>
does not make sense.rocketraman
02/18/2025, 2:45 PMHttpClientEngineBase
, which seems odd to me. Why would it use the IO dispatcher?bk9735732777
05/05/2025, 7:12 AMrocketraman
05/05/2025, 12:57 PMbk9735732777
05/07/2025, 6:27 AMsome may already be wrapped in an IO dispatcher by Ktor itself
or some other dispatcher also but this part,
but Some client calls may not be blocking
this part i don't get like won't network calls are always blocking if done on main thread. that is the reason we use coroutines right?rocketraman
05/07/2025, 12:43 PMjava.nio
is an abstraction over these platform-specific capabilities on the JVM/Android. Coroutines don't add any new capabilities here.
> that is the reason we use coroutines right?
What coroutines bring to the table is allowing these non-blocking calls to suspend so that we can write our program as if the call was blocking and synchronous, which makes our code much easier to understand.