On Tue, 14 Nov 2023 09:48:13 GMT, Rémi Forax <fo...@openjdk.org> wrote:

> Hello, the relation between a stateless gatherer (default initializer) and 
> the default combiner are not obvious to me.
> 
> A default initializer means stateless and a default combiner means 
> sequential, so if i want the integrator of my stateless gatherer to be called 
> in parallel, i need to not use the default combiner but at the same time the 
> combiner I will pass as parameter will not be called because the gatherer is 
> stateless ?
> 
> Having to create a combiner that will be not called seems weird. I'm sure i'm 
> missing something ?

It stems from the observation that the nature of something being stateless does 
not mean that it doesn't have restrictions on encounter order (see forEach and 
forEachOrdered as an example). Parallelization means foregoing encounter-order 
(of execution -- not necessarily of output), so by requiring to specify a 
combiner to opt into parallel (unordered execution) means that the default is 
correct and safe under all evaluation modes, and opting into out-of-order 
execution is inspectable (in terms of ocular inspection of code).

-------------

PR Comment: https://git.openjdk.org/jdk/pull/16420#issuecomment-1809940566

Reply via email to