Another thought - returning a 'true' Iterable (meaning that it actually 
supports multiple iterations) involves, in the general case, materializing 
the sequence (which may be arbitrarily long...) into memory, somewhat 
subverting one of the goals of streams, since it prevents laziness.

On Tuesday, September 26, 2017 at 10:36:08 PM UTC-7, Konrad Malawski wrote:
>
>
> Are multiple iterators ever needed to be requested from it?
>
> I'm kind of tempted to do
> Flow.<Iterator<T>>create().mapConcat(iter -> new Iterable<T>() {
>             @Override
>             public Iterator<T> iterator()
>             {
>                 return iter;
>             }}).grouped(chunkSize).map(list -> list.iterator())
>
>
> That’s what “multiple materializations of the same stream pipeline” are, 
> so yes.
>
> If returning the same iterator is what you want there then feel free to do 
> so; It means though that if you start 2 streams using a part of that 
> mapConcat would end up accessing the same iterator potentially concurrently.
>
> — Konrad
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to