Le 02/02/2013 15:32, Tom Van Cutsem a écrit :
2013/2/2 David Bruant <bruan...@gmail.com <mailto:bruan...@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
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to