Le jeudi 09 février 2006 à 17:25 +0100, Kevin Glynn a écrit :
> Aurélien Campéas writes:
> > Hello,
> >
> > pp 258-259 of CTM are about multiple readers for streams ...
> >
> > local Xs S1 S2 S3 in
> > thread Xs={Generate 0 150000} end
> > thread S1={Sum Xs 0} end
> > thread S2={Sum Xs 0} end
> > ...
> > end
> >
> > this implies that the stream a) is not really consummed by the threads,
> > hence b) the 150000 elements reside in memory c) it looks quite
> > difficult how to decide when to release them
> >
> > I'm really puzzled with this aspect of streams ... (I hope this isn't a
> > FAQ).
> >
>
> All data that is no longer reachable from any thread in the system is
> garbage and can be collected by a garbage collection. So, if Xs isn't
> used in the ... part of your example then any portion of Xs that has
> been processed by both Sum threads will be garbage. That is, we don't
> need to wait until the Sum threads have completed before reclaiming
> the space used by the finished with portion of Xs.
>
> So, in the best case if we were lucky with the scheduling of threads
> (you won't be!) then the above program could run in constant space.
But worst case implies growing the whole stream in memory.
>
> If we generated Xs lazily (sec 4.5 of CTM) and only consumed it once
> then it would run in constant space.
I was really looking for the bounded buffer solution of 4.3.3.2
Thanks,
Aurélien.
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users