voddan
02/28/2018, 3:29 PMlaunch(CommonPool.copy(parent = job)) {}
Starting to think that the + was too cryptic to begin withJonathan
02/28/2018, 3:31 PMCommonPool.copy(parent = job) even more cryptic.
Anyway, you can do launch(CommonPool, parent = job) {}voddan
02/28/2018, 3:34 PM.copy(a=b) is the same syntax as for data classes. What is cryptic about it?Jonathan
02/28/2018, 3:35 PMcopy with a data class, the class already have the property you want to change. CommonPool doesn't have any parent. It's only a thread dispatcher.Jonathan
02/28/2018, 3:41 PMx.copy(a=b) usually return an instance of the same type of x. Here it wouldn't be possible and wouldn't make sense as thread dispatcher never contains Job element. with + you explicitly build a new object (A context) which contains "the dispatcher + the job"deviant
02/28/2018, 3:46 PM+ and how Elements combined into one contextvoddan
03/01/2018, 8:55 AMCommonPool is a context with undefined parent. So conceptually there is no difference between + and copyvoddan
03/01/2018, 9:00 AM+ for forming contexts is that it is not explicit what part of context is changing. For example context + job replaces the current parent with job, but it is implicit. The launch(context, parent = job) is an attempt to fix that issue. In a sense, context.copy(parent = job) is + with explicit namingvoddan
03/01/2018, 9:10 AMcontext.copy(...) is that it is defined once for all context, not in every builder like launch. Plus it can be generalized to include other parameters like context.copy(name = ":)")Jonathan
03/01/2018, 9:16 AMCommonPool is not semantically a Context and this is my point. CommonPool is a `CoroutineDispatcher`which is an Element of Context. with + you explicitly create a new Context by assembling elements. Of course Element implements Context and this may be confusing. But for me it is quite natural to create a context with form like "dispatcher + job + whatever".Jonathan
03/01/2018, 9:25 AM+ is already "defined once for all context". As you said, there is conceptually no difference between the + and the copy you propose. Except that a good x.copy() function (IMO) should always return an instance of the same type than x (like it is the case for data classes). And this is is not possible with a CoroutineDispatcher. Because instances of `CoroutineDispatcher`would never contains any parent Job.voddan
03/01/2018, 9:36 AMContext.copy(parent, name, ...) been on the table ?deviant
03/01/2018, 9:42 AMelizarov
03/01/2018, 11:20 AMkotlinx.coroutines issue tracker and move discussion there.voddan
03/01/2018, 4:31 PM