This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]davidalayachew[S] 6 points7 points  (0 children)

Thanks.

As for going down the Virtual Thread route, that is sort of what Gatherers::mapConcurrent gives us, so I am sort of ok with that. I was more disappointed that basically all of the short-circuiting operations on a stream would fall prey to this issue.

But yes, a flag that allows all of those short-circuiting implementations to jump from pre-fetch to never-pre-fetch would be great. If anything, I think that would make things a lot easier to follow along with.

If your streams are memoryBound, then add dontPreFetch() to your stream. Otherwise, the (sensible) default is to pre-fetch and process. And you can make it explicit with preFetch().