What is the status of Weak References?
David Bruant
bruant.d at gmail.com
Sat Feb 2 07:47:11 PST 2013
Le 02/02/2013 15:32, Tom Van Cutsem a écrit :
> 2013/2/2 David Bruant <bruant.d at gmail.com <mailto:bruant.d at gmail.com>>
>
> About weakrefs, I've read a little bit [2][3] and I'm puzzled by
> one thing: the return value of get is a strong reference, so if a
> misbehaving component keeps this strong reference around, having
> passed a weak reference was pointless.
>
>
> For use cases where you're passing a reference to some
> plug-in/component and want the referred-to object to be eventually
> collected, we have revocable proxies. Weak references aren't the right
> tool when you want to express the guarantee that the component can no
> longer hold onto the object.
Indeed, it makes weak references a tool only useful within a trust
boundary (when you don't need to share the object reference with an
untrusted 3rd party).
Interestingly, revocable proxies require their creator to think to the
lifecycle of the object to the point where they know when the object
shouldn't be used anymore by whoever they shared the proxy with. I feel
this is the exact same reflections that is needed to understand when an
object isn't needed anymore within a trust boundary... seriously
questioning the need for weak references.
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130202/e37cb426/attachment.html>
More information about the es-discuss
mailing list