Hi
Thanks for your reply Peter.
What you say is exactly what I expected, however I'm still confused by
something.
If I change the sample to:
declare P in
local S in
P={NewPort S}
for X in S do {Browse X} {Browse S} end
end
Then each time I do Port.send I see one value for each new 'X' (as
expected) but S builds incrementally each time. If, as in my case, the
program is intended to run continuously won't the stream just get bigger
and bigger with no garbage collection ever being initiated?
I'm assuming here that the definition of 'S' as a local variable is what
should allow the garbage collector to 'clean up' the stream once the
local...end block finishes?
Regards
Mark
Peter Van Roy wrote:
mark richardson wrote:
Hi,
One more question if anyone can help.
Using ports as suggested gives me a stream which blocks until further
data is available, but is their a way to 'pop' values off the stream?
Ideally I want to read around 100 items from the stream, removing
them as I go. The amount of data to be read during one run of the
program will be very large and the stream will obviously grow as data
is received. However, the program is intended to loop continuously
and therefore I need to have some way of discarding processed stream
items.
Any suggestions?
Regards
Mark
'Popping' is automatic. For example:
declare P in
local S in
P={NewPort S}
for X in S do {Browse X} end
end
If you send to the port by doing '{Send P foobar}' then foobar will
appear on the stream S. As soon as it is handled in the for loop, it
becomes inaccessible and garbage collection can remove it.
Peter
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users