dave08
09/13/2018, 12:22 PMenleur
09/13/2018, 12:23 PMdave08
09/13/2018, 12:24 PMelizarov
09/13/2018, 2:08 PMdave08
09/13/2018, 3:11 PMlaunch something in the app's code, you still need a CoroutineScope... I don't know what Ktor will do for that anyways, what will be the Scope, a single request, the application?elizarov
09/13/2018, 8:31 PMelizarov
09/13/2018, 8:32 PMlaunch your coroutine in. If you plan to launch a coroutine in the scope of request, use the scope of request. If you plan to launch coroutine in the scope of your whole application, use GlobalScope.elizarov
09/13/2018, 8:33 PMcoroutineScope { ... }.dave08
09/14/2018, 6:00 AMcoroutineScope { } for each request, if there is a heavy load of requests? I'd understand for an Android Activity, but requests are things that come and go very quickly.
Also, I wonder how it would deal with a request timeout, how would it get cancelled (the scope, I mean)?
Also, the fact that Ktor is a DSL and not class based, makes it that nothing can just implement the regular CoroutineScope, so the right practice is to use coroutineScope { }?elizarov
09/14/2018, 6:42 AMCoroutineScope is. You only need to if you want to do some kind of parallel decomposition — make several operation concurrently. In this case, you delimit your block with coroutineScope { ... }dave08
09/14/2018, 6:45 AMdave08
09/14/2018, 6:47 AMdave08
09/14/2018, 6:47 AMelizarov
09/14/2018, 6:52 AMwithTimeout { ... }. It also creates a scope of all of the coroutines you launch (in parallel) inside of the block — they will all be cancelled on timeoutdave08
09/14/2018, 7:08 AMcoroutineScope {} will be cancelled if one of those operations in a withTimeout times out? And I suppose if I would surround all the operations with that withTimeout, it should also work. Thanks!
I wonder if it would be enough of a common case to warrent a coroutineScopeWithTimeout...