From: Mars Saxman <[EMAIL PROTECTED]>
Date: Fri, 5 Jan 2007 23:16:41 -0800
On Jan 5, 2007, at 10:46 PM, Mathieu Langlois wrote:
It's actually pretty trivial to implement weak references with a
plugin, all
you need to do is return the object without locking it.
Sounds like a recipie for a crash?
Even my ElfData plugin locks the objects it returns...
This is trivial only because it leaves the hard part of the problem
unsolved. When the object reaches the end of its life, all of these
fake "weak references" will become dangling references, pointing at
an object which no longer exists. Breaking the memory management
system like this is not a good idea unless you have too much free
time and want to spend it solving tricky bugs.
My ElfData plugin has a RingTree class, which does properly implement
"weak references", but only for one tree node to another tree node :)
It's got no bugs in it also.
To be honest, I can't remember another situation except for trees
where I actually needed weak refs. Well maybe a double-linked list...
but my tree is essentially a double linked list with a bit ontop.
--
http://elfdata.com/plugin/
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>