Hi Ron,
thinking a bit while implementing a simplification to cleanup
(attached) I wondered whether it is such a good idea to move all
the responsibility for cleaning up to an inner state of a consumer
stream. This seems like calling for trouble later, as most people
would not bother to implement it if they have a stream they want to
end somehow. Also we don't want to create responsibility in places
that don't relate directly to the cleanup.
we seem to have the trade off:
# Problem 1: calling more values from upstream than actually played
# Problem 2: having to check every single event for whether it
contains things to be done. Difficult implementation.
What about this: any stream that needs to be released adds some
hook to itself (or a cleanup event) to every _downstream_ event.
Then all we have to call is some finish function in this event, and
remove the hook. I think this would solve both problems.
// may not be needed:
//////////////////////////////////
EventCleanup {
var functions;
*new {
^super.newCopyArgs(IdentitySet.new) // btw far more efficient!
}
add { arg event;
event[\addToCleanup].do { | f | functions.add(f) };
event[\removeFromCleanup].do { | f | functions.remove(f) };
}
cleanup { arg inevent, outevent;
functions.do { | f | f.value(inevent) };
outevent[\removeFromCleanup] = functions.union(outevent
[\removeFromCleanup]);
^outevent
}
}
--
.
_______________________________________________
Sc-devel mailing list
Sc-devel@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-devel