Constructing parallel streams
Paul Sandoz
paul.sandoz at oracle.com
Mon Dec 10 08:17:58 PST 2012
On Dec 10, 2012, at 4:50 PM, Brian Goetz <brian.goetz at Oracle.COM> wrote:
>> I don't like users being able to call parallel in the middle of the
>> stream construction.
>
> I don't love it either. The semantics are perfectly tractible, and the implementation is perfectly straightforward, but the performance is unlikely to be a win in most cases. (I mentioned earlier we would doc that this really should only be done at the head of the pipeline.)
>
>> I propose to have an interface ParallelizableStream that allows to
>> choose if the user want the sequential or the parallel stream upfront.
>
> Yeah, we investigated this direction first. Combinatorial explosion: IntParallelizableStream, etc.
>
> However, this could trivially become a dynamic property of streams (fits easily into the existing stream flags mechanism). Then only the head streams would have the property, and if you tried to do parallel() farther down the stream, we could ignore it or even throw ISE.
>
There might be cases were a stream is handed off to something else that wants to go parallel for stuff further down.
Paul.
More information about the lambda-libs-spec-observers
mailing list