Boriss Mejias wrote:
Raphael Collet wrote:
Dear Ashis,

The port only keeps a reference to the unbound tail of the stream. It does not keep alive all former messages that were sent.

Sorry for joining late, but, if you have a pointer to the beginning of the stream, then all the messages sent to that port will stay in the stream and not be garbage collected. is that right? for instance:

declare
S P
P = {NewPort S}
thread
   for Msg in S do
      {Browse Msg}
   end
end

That will keep the whole stream of messages because you can always access S.

An alternative code would be

declare
P
thread
   S
in
   P = {NewPort S}
   for Msg in S do
      {Browse Msg}
   end
end

on this second code you don't need to keep the whole stream, and then the garbage collector should be able to do its job.

I also like this short version of the code which I found in the Mozart sources a while ago:

declare
P
thread
 for Msg in {NewPort $ P} do
   {Browse Msg}
 end
end

With this code, there is no temptation to make the scope of the stream too wide.

Cheers,
 Wolfgang

_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to