i have been thinking about event.pm and ref counts of watchers. it seems
to me that class subs like all_watchers() imply you keep class data with
refs to all existing watchers. this means if a watcher object goes out
of scope at the higher/caller level, it won't be ref counted to 0 and be
stopped and garbage collected. this would mean watchers must be
explicitly stopped to remove them from the system.

this is not a bad thing in and of itself. i have a similar problem with
my higher level events which sit on event.pm. my example is a circular
link with the accept object. i need the accept object to have a readable
method and that object also holds the watcher which has a ref to the
accept object in the cb attribute. there is the circular link. so if the
accept object goes out of scope it will not be garbage collected and
memory is leaked and the socket stays open.

i gather weak references will solve this but that is in 5.6 which will
be out real soon now! :-)

so i will have to require explicit shutting down of an accept object to
stop it and cause garbage collection. the shutdown method will stop the
watcher and break the circular link.

no big problem, just wanted to clear my thoughts on this. let me know
what you think about it and if you have a better way.

uri

-- 
Uri Guttman  ---------  [EMAIL PROTECTED]  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com

Reply via email to