[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] Re: Object.addDependant / update



On Jan 30, 2006, at 4:33 AM, Item State wrote:

    n = NodeWatcher.newFrom( s );
    s = Synth.new( \default );
    n.register( s );
    s.addDependant({ arg obj, what; if( what ==
\n_end, { "it died!".postln; }); });
    s.sendBundle( 4.0, [[ "/n_free", s.nodeID ]]);

Hey sciss,

Don't forget to remove the node from the dependent dictionary using s.releaseDependants--otherwise, the dictionary will get cluttered up with useless Synth objects that will never get garbage collected. You can do that inside the updater function.

NodeWatcher does its own garbage collection, but dependents do not.

Come to think of it, maybe NodeWatcher-n_end should automatically kill dependencies on the node? I know it wouldn't break any of my usage, but it might be overkill.

I mean, now I can do s.addDependant( Updater({ arg
obj, what; ... }));

Updater automatically adds itself as a dependent. s.addDependant(Updater(...)) is redundant.

hjh

PS, semi off topic, why was the word "dependent" misspelled when creating the dependency protocol?

: H. James Harkins
: jamshark70@xxxxxxxxxxxxxxxxx
: http://www.dewdrop-world.net
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman