https://kotlinlang.org logo
#coroutines
Title
# coroutines
b

bj0

09/29/2017, 11:49 PM
I was just thinking it would be nice if you were only working in a single context (like UI, or a single thread), that it would be nice to make the default "keep using current context"
e

elizarov

09/30/2017, 6:59 AM
That is how .NET did and it, and this idea did not went well.
b

bj0

09/30/2017, 2:39 PM
what do you mean?
e

elizarov

09/30/2017, 2:49 PM
Google for “.net task configureawait”. That’s the boilerplate that every library author has to use and be very careful not to foreget
b

bj0

09/30/2017, 4:19 PM
I still don't understand, that controls where the continuation resumes right? I don't see why that would have to change for kotlin, I'm just talking about which context to schedule the coroutine in
for instance, if I am doing I/O in a newSingleThreadContext, but it's broken into a few different functions. Instead of adding a context variable to each function and passing it around, there could be a
currentContext
that just schedules the coroutine on the parent's context. Being able to set that as the default (maybe not permanently) would just mean not having to type
(currentContext())
everywhere
d

dave08

10/01/2017, 6:44 AM
@elizarov I also don't see why in Vert.x or Swing or Android, the Default should not be according to it's own thread model... It might be something an end user might forget, but for someone developing a lib for interaction w/ these platforms, it could certainly be nice...
3 Views